Dealing with non-callable classmethod objects
Ian Pilcher
arequipeno at gmail.com
Sat Nov 12 17:46:39 EST 2022
On 11/12/22 14:57, Cameron Simpson wrote:
> You shouldn't need a throwaway class, just use the name "classmethod"
> directly - it's the type!
>
> if not callable(factory):
> if type(factory) is classmethod:
> # replace fctory with a function calling factory.__func__
> factory = lambda arg: factory.__func__(classmethod, arg)
> else:
> raise TypeError("unhandled factory type %s:%r" %
> (type(factory), factory)
> value = factory(d[attr])
Or I could use the C++ version:
face << palm;
Thanks!
--
========================================================================
Google Where SkyNet meets Idiocracy
========================================================================
More information about the Python-list
mailing list