Re: super() in injected methods

2021-02-12 Thread Andras Tantos
On 2/11/21 10:35 PM, Greg Ewing wrote: On 12/02/21 3:39 pm, Andras Tantos wrote: Now, when a Port gets assigned a NetType, it needs to gain all sorts of new features. It for example should have a 'length' attribute that tells how many bits are needed to represent its possible val

Re: super() in injected methods

2021-02-11 Thread Andras Tantos
On 2/11/21 1:43 PM, Greg Ewing wrote: On 12/02/21 7:05 am, Andras Tantos wrote:      a = B()      a.m(41)      a.m = MethodType(method, a)      a.m(42) Are you sure you really need to inject methods into instances like this? What problem are you trying to solve by doing so? There's a

Re: super() in injected methods

2021-02-11 Thread Andras Tantos
Chris, Thanks for the reply! On 2/11/21 11:08 AM, Chris Angelico wrote: On Fri, Feb 12, 2021 at 5:54 AM Andras Tantos wrote: Esteemed Python Gurus, I think, I actually know the answer to this question, but - maybe beyond reason - I'm hoping there to be some magic. Consider the foll

super() in injected methods

2021-02-11 Thread Andras Tantos
27;self' at the point of method binding to class) is available at the point of method injection, in this example, the next-to-last line of the code. So, is there a way to somehow inject/override/magically-make-it-appear the __class__ cell in 'method' such that super() starts wor

Re: How to set custom locals for function call?

2020-09-01 Thread Andras Tantos
On 9/1/20 5:31 PM, Chris Angelico wrote: On Wed, Sep 2, 2020 at 10:23 AM Andras Tantos wrote: I did see these macros in the CPython source code. What it seems to imply is that if I wanted to do what I intend, that is to hook every local variable assignment, I would have to modify the AST

Re: How to set custom locals for function call?

2020-09-01 Thread Andras Tantos
Snipping old parts... On 9/1/20 4:01 PM, Chris Angelico wrote: On Wed, Sep 2, 2020 at 8:44 AM Andras Tantos wrote: While I'm sure you're right, it certainly is well hidden: ... In other words, I can indeed change the value of a local variable through the locals() dict. Not q

Re: How to set custom locals for function call?

2020-09-01 Thread Andras Tantos
On 9/1/20 1:42 PM, Chris Angelico wrote: On Wed, Sep 2, 2020 at 5:00 AM Andras Tantos wrote: All, I'm new here, so please direct me to the right forum, if this is not the one... What I'm trying to do is to call a function, but monitor all the local variable accesses within tha

Re: How to set custom locals for function call?

2020-09-01 Thread Andras Tantos
On 9/1/2020 12:41 PM, MRAB wrote: On 2020-09-01 05:45, Andras Tantos wrote: All, I'm new here, so please direct me to the right forum, if this is not the one... What I'm trying to do is to call a function, but monitor all the local variable accesses within that function. What I

How to set custom locals for function call?

2020-09-01 Thread Andras Tantos
the functions |__code__| member, I end up executing pre-compiled byte-code which has already assumptions about the locals dict built into it. If I'm right (or even if I'm not), what is the right way to achieve my goal: that local assignments get redirected to the supplied dictio