More __init__ methods
Tim Golden
mail at timgolden.me.uk
Thu Nov 6 13:44:04 EST 2008
Mr.SpOOn wrote:
> On Thu, Nov 6, 2008 at 4:59 PM, Marc 'BlackJack' Rintsch <bj_666 at gmx.net> wrote:
>> class A(object):
>> def __init__(self, a, b, c):
>> self.a = a
>> # ...
>>
>> @classmethod
>> def from_string(cls, s):
>> # ...
>> return cls(a, b, c)
>
> Thanks.
> I think it's time to study decorators.
While that's no bad thing, you don't really need to do
that simply to understand these examples: they're just
saying "do whatever you need to to make these method
class methods, not instance methods".
TJG
More information about the Python-list
mailing list