classmethod & staticmethod

Alex Popescu nospam.themindstorm at gmail.com
Tue Jul 24 20:55:17 EDT 2007


Neil Cerutti <horpner at yahoo.com> wrote in news:eRwpi.36813$G23.28496
@newsreading01.news.tds.net:

> On 2007-07-25, Alex Popescu <nospam.themindstorm at gmail.com> wrote:
>> As a matter of style, how do you figure out that class_list is
>> a class attribute and not an instance attribute? (I don't
>> remember seeing anything in the PEP describing the coding
>> style).
> 
> Check out dir(MyClass) and dir(MyClass()) for some insight, if it
> turns out that it matters. 

I must confess that I am a bit confused by this advise, as both are 
returning exactly the same thing.

> Preferably, the user of a class
> doesn't have to really think about it much.
> 
I know that this would be prefered, but in case you are getting 3rd party 
code and you modify a class attribute without knowing it is a class 
attribute then you may get into trouble (indeed the real problem is with 
the designer of the 3rd party code, but still I think it is a valid 
concern).

tia,
./alex
--
.w( the_mindstorm )p.





More information about the Python-list mailing list