Is static variable and static function concept available in Python?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psbasha
    Contributor
    • Feb 2007
    • 440

    #1

    Is static variable and static function concept available in Python?

    Hi,

    Is static variable and static function concept available in Python?

    Thanks in advance
    PSB
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by psbasha
    Hi,

    Is static variable and static function concept available in Python?

    Thanks in advance
    PSB
    Python has very simple scope rules for variables, functions, objects, etc. Static methods can be defined in classes with the @staticmethod decorator or the staticmethod() function.

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by psbasha
      Hi,

      Is static variable and static function concept available in Python?

      Thanks in advance
      PSB
      New Style classes have gotten some "decorators " to help in this regard. They're described in PEP 318 in the docs. You can read about them here.

      I like BV's answer better than this one.
      Last edited by bartonc; Mar 9 '07, 02:39 AM. Reason: BV beat me to it

      Comment

      Working...