Python style question
Martin Pool
mbp at sourcefrog.net
Mon Jun 6 14:35:22 BST 2005
On 6 Jun 2005, Aaron Bentley <aaron.bentley at utoronto.ca> wrote:
> Martin Pool wrote:
>
> | Hm, I don't really understand your mail though... if you did want an
> | abstract factory then a static method would seem to be the right
> | way, and I didn't speak of class methods...
>
> AIUI, there are no static methods in Python. The closest thing is a
> class method.
Try 'pydoc staticmethod'.
The difference is that classmethods receive their the class as a first
parameter comparable to self, and static methods do not.
staticmethods are like in Java, and classmethods are more powerful -
for example one can have a class method that acts as a quasi-constructor, returning
an instance of the subclass on which it was invoked.
--
Martin
More information about the bazaar
mailing list