method that can be called from a class and also from an instance

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Nov 22 23:23:22 EST 2012


On Thu, 22 Nov 2012 07:14:29 -0800, Marc Aymerich wrote:

> Hi,
> 
> I want to create a method within a class that is able to accept either a
> class or an instance.

You want my "dualmethod" decorator:

http://code.activestate.com/recipes/577030/




-- 
Steven




More information about the Python-list mailing list