why is there no class (static) methods in Python ?

Remco Gerlich scarblac at pino.selwerd.nl
Tue Jun 19 07:10:24 EDT 2001


Richard Gruet <rgruet at intraware.com> wrote in comp.lang.python:
> No, I completely disagree. WHY should they be *global* functions rather than
> *class* functions (since they are strictly related to the class) ? You provide no
> arguments ! Using the class namespace rather than the module namespace for
> class-related functions seems more natural (and object oriented) to me.

To me, a class defines what you can do with instances. It's like a blueprint
for an instance. Functions that do something with an instance are inside the
class.

On the other hand, functions that don't operate on a specific instance but
on the class as a whole, are not part of the blueprint, but something that
acts on the blueprint, and should therefore be defined outside of it.

> And finally, I wonder why they are class methods in Java ? They should listen to
> your arguments and remove them ;-)

Java no standalone functions... even main() is a class method. If you want
to take that brain-damaged design as an example, don't expect me to follow
:-)

> But I don't want to dispute endlessly. I -and other people- would simply like
> that such a feature be available in Python, that's all!

Class methods would be a bit nicer when inheriting from a class. That's the
main point in favor of them, imo.

-- 
Remco Gerlich



More information about the Python-list mailing list