Does python have the static function member like C++

7stud bbxx789_05ss at yahoo.com
Tue Apr 10 23:23:18 EDT 2007


On Apr 10, 9:08 pm, "人言落日是天涯,望极天涯不见家" <kelvin.... at gmail.com> wrote:
> I define the class like this:
> class AAA:
>     counter = 0
>     def __init__(self):
>         pass
>     def counter_increase():
>         AAA.counter += 1
>         print "couter now :", AAA.counter
>
> But how could I call the function "counter_incrrease" ?
>
> Thanks !

You can also do this:

class AAA:
    counter = 0
    def __init__(self):
        pass

AAA.counter += 1
print AAA.counter


More information about the Python-list mailing list