class methods?

Stuart Zakon sjz18 at yahoo.com
Wed Jan 12 09:54:48 EST 2000


Is there no such thing as class scope methods in Python? (Analogous to static
methods in Java, C++).

I have a class scope dictionary that I am using to collect statistics on method
invocations of the class instances and I wanted to have a class method to print
them out. 

However, Python seems to want a class instance to call a method. Does every
method on a class need self as a parameter?

Certainly I could make a separate statistics class and instantiate it once;
however, the nature of the problem is such that it is more natural for the
statistics collection to be private to the original class.

If I am missing something, I apologize, but coming from Java and C++ it just
seemed natural to have this feature. If there can be class attributes, then why
not class methods? My understanding is that this is natural for Smalltalk as
well.

Stuart Zakon
Objects by Design
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com




More information about the Python-list mailing list