pass object or use self.object?
Xavier Ho
contact at xavierho.com
Tue Apr 6 11:35:01 EDT 2010
On Wed, Apr 7, 2010 at 1:19 AM, Jean-Michel Pichavant <
jeanmichel at sequans.com> wrote:
> Usually, when using classes as namespace, functions are declared as static
> (or as classmethod if required).
> e.g.
>
>
> class Foo:
> @classmethod
> def process(cls, document):
> print 'process of'
> cls.foo(document)
>
> @staticmethod
> def foo(document):
> print document
>
> In [5]: Foo.process('my document')
> process of
> my document
>
>
> There is no more question about self, 'cause there is no more self. You
> don't need to create any instance of Foo neither.
JM, I beg to differ. If many functions are static inside a class, I would
simply put those methods right under a module instead.
My 2c,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100407/927dcce3/attachment-0001.html>
More information about the Python-list
mailing list