Code snippet: dualmethod descriptor

Gabriel Genellina gagsl-py2 at
Thu Feb 4 04:09:02 CET 2010

En Sat, 30 Jan 2010 03:06:18 -0300, Steven D'Aprano
<steve at> escribió:

> class dualmethod(object):
>     """Descriptor implementing dualmethods (combination
>     class/instance method).
>     Returns a method which takes either an instance or a class as
>     the first argument. When called on an instance, the instance is
>     passed as the first argument. When called as a class, the class
>     itself is passed instead.

Seems useful!
Perhaps a better place to post it would be
<>, at least it's easier
to search.

Gabriel Genellina

More information about the Python-list mailing list