Mr.SpOOn <[EMAIL PROTECTED]> writes: > On Thu, Nov 6, 2008 at 4:59 PM, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> > 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.
Studying decorators is a good idea, but in this instance it's not necessary. The above is merely using decorator syntax to apply the ‘classmethod’ type to a function. All you need to know to understand the above is that it will have essentially the same result as: class A(object): # ... def _from_string(cls, s): # ... return cls(a, b, c) from_string = classmethod(_from_string) del _from_string without the intermediate binding of the ‘_from_string’ name. -- \ “The best way to get information on Usenet is not to ask a | `\ question, but to post the wrong information.” —Aahz | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list