New-style classes and special methods
Andrew Bennetts
andrew-pythonlist at puzzling.org
Mon Feb 24 02:38:57 EST 2003
On Mon, Feb 24, 2003 at 07:13:44AM +0000, Carl Banks wrote:
> Jp Calderone wrote:
> > [-- text/plain, encoding quoted-printable, 37 lines --]
> >
> > Consider this class:
> >
> > class Foo:
> > def __getattr__(self, name):
> > return lambda arg: arg
> >
> > It can be used thusly:
> >
> > f = Foo()
> > print f[10]
>
> Sure?
>>> class Foo:
... def __getattr__(self, name):
... return lambda arg: arg
...
>>> f = Foo()
>>> print f[10]
10
Yep, I'd say he's sure.
-Andrew.
More information about the Python-list
mailing list