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


Groups > comp.lang.python > #105572

Re: monkey patching __code__

From "Sven R. Kunze" <srkunze@mail.de>
Newsgroups comp.lang.python
Subject Re: monkey patching __code__
Date 2016-03-23 23:06 +0100
Message-ID <mailman.69.1458770767.2244.python-list@python.org> (permalink)
References (1 earlier) <CAG93HwGKrN8y3k=3OFtHq-PbMjFzy=1U99-ZuJOLdEq69gosfg@mail.gmail.com> <56EED3DE.7050101@mail.de> <CAG93HwFr-yFqjex_U4yZs5WUuLCCbCJDJfso2Kp6G0F3BdKOZQ@mail.gmail.com> <56F13417.8060108@mail.de> <87egb1vbyn.fsf@handshake.de>

Show all headers | View raw


On 23.03.2016 09:24, dieter wrote:
> But you have observed that you cannot do everything with a
> code substitution: a function call does not only depend on the code
> but also on other properties of the function object: e.g. the
> parameter processing.

Yep, that's because Python is very flexible and provides means for 
changing even that. So, it's not part of the __code__ object but part of 
the actual function. That's okay.

> You might be able to change them in a similar way as "__code__" (i.e.
> direct modification). Otherwise, you would need to construct a new
> "function object" -- and lose the possibility to completely
> change the function object in place.

Exactly. Except __globals__ we are all set and I think that'll work for 
us. I will report once we've implemented it that way.

Best,
Sven

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


Thread

Re: monkey patching __code__ "Sven R. Kunze" <srkunze@mail.de> - 2016-03-23 23:06 +0100

csiph-web