why is there no class (static) methods in Python ?
Martin von Loewis
loewis at informatik.hu-berlin.de
Sun Jun 17 16:34:55 EDT 2001
Richard Gruet <rgruet at intraware.com> writes:
> I (and other people on the Python french mail list) wonder why there
> are no class (static) methods in Python. You cannot define a really
> unbounded (ie to an instance) method within the namespace of a class.
First of all, you *can* define such a thing if you absolutely want, see
> It's not natural nor elegant to have to create an instance to call a
> method which is not related to a particular instance. We would like to
> be able to write things like:
> class C:
> def staticFoo(x): print x
I'd like to question why you want to do this. Isn't it much better to write
I.e. what has class C to do with staticFoo?
More information about the Python-list