Re: __class__ of what

2010-08-12 Thread Stefan Schwarzer
Hello Jean-Michel, On 2010-08-12 16:06, Jean-Michel Pichavant wrote: > Eric J. Van der Velden wrote: > Should be > > class C: > n = 0 > def __init__(self): >self.__class__.n+=1 >C.n+=1 # equivalent to this line (I prefer this one, more > readable, less refactor-friendly)

Re: __class__ of what

2010-08-12 Thread Peter Otten
Eric J. Van der Velden wrote: > I have, > > class C: > n=0 > def __init__(s): > __class__.n+=1 > > > I do C() > > This is fine. But of what thing I am taking the __class__ of? > I can also do > > @staticmethod > def p(): > p

Re: __class__ of what

2010-08-12 Thread Eric Brunel
In article <72151646-65cb-47bb-bd55-e7eb67577...@z10g2000yqb.googlegroups.com>, "Eric J. Van der Velden" wrote: > Hello, > > I have, > > class C: > n=0 > def __init__(s): > __class__.n+=1 > > > I do > >>> C() > > This is fine. No it's not, at least in Pytho

Re: __class__ of what

2010-08-12 Thread Jean-Michel Pichavant
Eric J. Van der Velden wrote: Hello, I have, class C: n=0 def __init__(s): __class__.n+=1 Should be class C: n = 0 def __init__(self): self.__class__.n+=1 C.n+=1 # equivalent to this line (I prefer this one, more readable, less refactor-

__class__ of what

2010-08-12 Thread Eric J. Van der Velden
Hello, I have, class C: n=0 def __init__(s): __class__.n+=1 I do >>> C() This is fine. But of what thing I am taking the __class__ of? I can also do @staticmethod def p(): print(__class__.n) >>> C.p() 1 Thanks, Eric J. --