Re: Code snippet: dualmethod descriptor

2010-02-06 Thread Arnaud Delobelle
Steven D'Aprano writes: > On Thu, 04 Feb 2010 00:09:02 -0300, Gabriel Genellina wrote: > >> En Sat, 30 Jan 2010 03:06:18 -0300, Steven D'Aprano >> escribió: >> >>> class dualmethod(object): > [...] > >> Seems useful! >> Perhaps a better place to post it would be >>

Re: Code snippet: dualmethod descriptor

2010-02-04 Thread Steven D'Aprano
On Thu, 04 Feb 2010 00:09:02 -0300, Gabriel Genellina wrote: > En Sat, 30 Jan 2010 03:06:18 -0300, Steven D'Aprano > escribió: > >> class dualmethod(object): [...] > Seems useful! > Perhaps a better place to post it would be > , at least it's >

Re: Code snippet: dualmethod descriptor

2010-02-03 Thread Gabriel Genellina
En Sat, 30 Jan 2010 03:06:18 -0300, Steven D'Aprano 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

Code snippet: dualmethod descriptor

2010-01-29 Thread Steven D'Aprano
I came up with this descriptor a few years ago, but never used it for anything. I've just found an actual use for it in my own code, so I thought I'd make it public for anyone else who might have a use for it. Use-case: if you have a class without an __init__ or __new__ method, then this may be