Referring to class methods in class attributes
Stephen Hansen
apt.shansen at gmail.com
Wed Feb 17 13:51:11 EST 2010
On Wed, Feb 17, 2010 at 10:38 AM, mk <mrkafk at gmail.com> wrote:
> Thanks, that worked. But in order to make it work I had to get rid of
> 'self' in print_internal_date signature, bc all other functions in tagdata
> have only a single argument:
>
Right, I should have caught that.
You can make print_internal_date a @staticmethod.
Or just leave it as a top level function where it was perfectly happy to
live :)
> That looks weird: a method with no 'self'. Hmm that is probably seriously
> wrong.
>
> This obviously means no other method can call it like
> self.print_internal_date(), because self would get passed as first argument,
> yes?
>
It doesn't have to be. It could be a class method-- @classmethod does that,
makes it receive 'cls' the actual class as the first argument. Or a
@staticmethod, in which case it has no first-argument at all.
--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100217/c33e62fa/attachment-0001.html>
More information about the Python-list
mailing list