Re: Does python have the static function member like C++

2007-04-11 Thread goodwolf
On Apr 11, 10:15 am, Bruno Desthuilliers wrote: > goodwolf a écrit : > > > > > On Apr 11, 9:09 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > >> goodwolf a écrit : > >> (snip) > > >>> 1. In this case you will prefer a classmethod instead a staticmethod. > >>> 2. If counter is the number of

Re: Does python have the static function member like C++

2007-04-11 Thread Bruno Desthuilliers
goodwolf a écrit : > On Apr 11, 9:09 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> goodwolf a écrit : >> (snip) >> >>> 1. In this case you will prefer a classmethod instead a staticmethod. >>> 2. If counter is the number of instances of class AAA then you will >>> incrase counter inside __i

Re: Does python have the static function member like C++

2007-04-11 Thread goodwolf
On Apr 11, 9:09 am, Bruno Desthuilliers wrote: > goodwolf a écrit : > (snip) > > > 1. In this case you will prefer a classmethod instead a staticmethod. > > 2. If counter is the number of instances of class AAA then you will > > incrase counter inside __init__ method. > > > class AAA (object): > >

Re: Does python have the static function member like C++

2007-04-11 Thread Bruno Desthuilliers
goodwolf a écrit : (snip) > 1. In this case you will prefer a classmethod instead a staticmethod. > 2. If counter is the number of instances of class AAA then you will > incrase counter inside __init__ method. > > class AAA (object): > counter = 0 > def __init__(self): > type(self)

Re: Does python have the static function member like C++

2007-04-11 Thread Bruno Desthuilliers
人言落日是天涯,望极天涯不见家 a écrit : > 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 You probably want something like this: class AAA(object): _co

Re: Does python have the static function member like C++

2007-04-10 Thread goodwolf
On Apr 11, 5:19 am, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 10, 9:08 pm, "人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> wrote: > > > I define the class like this: > > class AAA: > > counter = 0 > > def __init__(self): > > pass > > def counter_increase(): > > AAA.counter += 1

Re: Does python have the static function member like C++

2007-04-10 Thread bearophileHUGS
> Many thanks for you! > I've never heard of the "staticmethod" , that's great! Note that you don't need an empty __init__ : class AAA: counter = 0 @staticmethod def counter_increase(): AAA.counter += 1 print "couter now:", AAA.counter AAA.counter_increase() Bye, be

Re: Does python have the static function member like C++

2007-04-10 Thread 人言落日是天涯,望极天涯不见家
On Apr 11, 11:19 am, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 10, 9:08 pm, "人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> wrote: > > > I define the class like this: > > class AAA: > >     counter = 0 > >     def __init__(self): > >         pass > >     def counter_increase(): > >         AAA.counter += 1

Re: Does python have the static function member like C++

2007-04-10 Thread 7stud
On Apr 10, 9:08 pm, "人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> 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

Re: Does python have the static function member like C++

2007-04-10 Thread 7stud
On Apr 10, 9:08 pm, "人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> 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

Does python have the static function member like C++

2007-04-10 Thread 人言落日是天涯,望极天涯不见家
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 ! -- http://mail.python.org/mailman/listinf