Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63647

Re: Monkeypatching a staticmethod?

From Piet van Oostrum <piet@vanoostrum.org>
Newsgroups comp.lang.python
Subject Re: Monkeypatching a staticmethod?
Date 2014-01-10 15:04 +0100
Message-ID <m28uuoue48.fsf@cochabamba.vanoostrum.org> (permalink)
References <roy-CE7D46.00231110012014@news.panix.com> <mailman.5292.1389339158.18130.python-list@python.org>

Show all headers | View raw


Ian Kelly <ian.g.kelly@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@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Monkeypatching a staticmethod? Roy Smith <roy@panix.com> - 2014-01-10 00:23 -0500
  Re: Monkeypatching a staticmethod? Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-10 00:31 -0700
    Re: Monkeypatching a staticmethod? Piet van Oostrum <piet@vanoostrum.org> - 2014-01-10 15:04 +0100

csiph-web