More __init__ methods

Ben Finney bignose+hates-spam at benfinney.id.au
Thu Nov 6 17:01:41 EST 2008


Arnaud Delobelle <arnodel at googlemail.com> writes:

> Ben Finney <bignose+hates-spam at benfinney.id.au> writes:
> [...]
> > 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.
> 
> So you mean it is the same as:
> 
> class A(object):
>     # ...
> 
>     def from_string(cls, s):
>         # ...
>     from_string = classmethod(from_string)

Sure, but I figured I would make the steps more explicit.

-- 
 \          “Writing a book is like washing an elephant: there no good |
  `\        place to begin or end, and it's hard to keep track of what |
_o__)                              you've already covered.” —anonymous |
Ben Finney



More information about the Python-list mailing list