[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Referring to class methods in class attributes

mk

2/18/2010 10:00:00 AM

Stephen Hansen wrote:
> Or just leave it as a top level function where it was perfectly happy to
> live :)

Yes. This is probably the sanest solution anyway, because probably
having many such functions to use, packing them into smth like
package.utils anyway is a good idea. I'm trying mainly to learn and
test-drive such solutions, not that I would be keen to use them
excessively in production code.

> 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.

Ahh now I get it. Thanks! So that's the use for @staticmethod (I was
wondering if there was any).