Monkeypatching a staticmethod?

Piet van Oostrum piet at vanoostrum.org
Fri Jan 10 09:04:55 EST 2014


Ian Kelly <ian.g.kelly at gmail.com> writes:

> I suggest defining x as a normal function and writing the assignment
> as "Foo.x = staticmethod(x)" to keep x callable from the global
> namespace.  Or just del it after doing the monkey patch.

You can use Foo.x = staticmethod(lambda: 2)
-- 
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]



More information about the Python-list mailing list