Re: How do I give a decorator acces to the class of a decorated function

2019-09-05 Thread Chris Angelico
On Fri, Sep 6, 2019 at 4:33 AM Serhiy Storchaka wrote: > > 04.09.19 17:21, Antoon Pardon пише: > > What I am trying to do is the following. > > > > class MyClass (...) : > > @register > > def MyFunction(...) > > ... > > > > What I would want is for the register decorator to some

Re: How do I give a decorator acces to the class of a decorated function

2019-09-05 Thread Serhiy Storchaka
04.09.19 17:21, Antoon Pardon пише: What I am trying to do is the following. class MyClass (...) : @register def MyFunction(...) ... What I would want is for the register decorator to somehow create/mutate class variable(s) of MyClass. Is that possible or do I have to rethin

Re: How do I give a decorator acces to the class of a decorated function

2019-09-05 Thread Peter Otten
Antoon Pardon wrote: > On 5/09/19 15:30, Peter Otten wrote: >> Can you provide some context? > > Sure I am researching the possibility of writing an easy to use > lexing/parsing tool. The idea is to write your lexer/parser as > follows: > > class Calculator(metaclass = ...): > def __init__(

Re: How do I give a decorator acces to the class of a decorated function

2019-09-05 Thread Antoon Pardon
On 5/09/19 15:30, Peter Otten wrote: >> 2) Is it possible to make MyClass automatically a subclass of an other >> class >>through the metaclass? >> > While you can modify `bases` before passing it on to `type` this starts to > get a bit messy. Maybe you need a real metaclass which unlike the r

Re: How do I give a decorator acces to the class of a decorated function

2019-09-05 Thread Peter Otten
Antoon Pardon wrote: > On 4/09/19 17:46, Peter Otten wrote: >> Antoon Pardon wrote: >> >>> What I am trying to do is the following. >>> >>> class MyClass (...) : >>> @register >>> def MyFunction(...) >>> ... >>> >>> What I would want is for the register decorator to somehow create/

Re: How do I give a decorator acces to the class of a decorated function

2019-09-05 Thread Antoon Pardon
On 4/09/19 17:46, Peter Otten wrote: > Antoon Pardon wrote: > >> What I am trying to do is the following. >> >> class MyClass (...) : >> @register >> def MyFunction(...) >> ... >> >> What I would want is for the register decorator to somehow create/mutate >> class variable(s) of MyC

Re: How do I give a decorator acces to the class of a decorated function

2019-09-05 Thread Antoon Pardon
On 4/09/19 17:46, Peter Otten wrote: > Antoon Pardon wrote: > >> What I am trying to do is the following. >> >> class MyClass (...) : >> @register >> def MyFunction(...) >> ... >> >> What I would want is for the register decorator to somehow create/mutate >> class variable(s) of MyC

Re: How do I give a decorator acces to the class of a decorated function

2019-09-04 Thread dieter
Antoon Pardon writes: > What I am trying to do is the following. > > class MyClass (...) : > @register > def MyFunction(...) > ... > > What I would want is for the register decorator to somehow create/mutate > class variable(s) of MyClass. > > Is that possible or do I have to rethi

Re: How do I give a decorator acces to the class of a decorated function

2019-09-04 Thread Peter Otten
Antoon Pardon wrote: > What I am trying to do is the following. > > class MyClass (...) : > @register > def MyFunction(...) > ... > > What I would want is for the register decorator to somehow create/mutate > class variable(s) of MyClass. > > Is that possible or do I have to ret

Re: How do I give a decorator acces to the class of a decorated function

2019-09-04 Thread Chris Angelico
On Thu, Sep 5, 2019 at 12:23 AM Antoon Pardon wrote: > > What I am trying to do is the following. > > class MyClass (...) : > @register > def MyFunction(...) > ... > > What I would want is for the register decorator to somehow create/mutate > class variable(s) of MyClass. > > Is th

Re: How do I give a decorator acces to the class of a decorated function

2019-09-04 Thread Rhodri James
On 04/09/2019 15:21, Antoon Pardon wrote: What I am trying to do is the following. class MyClass (...) : @register def MyFunction(...) ... What I would want is for the register decorator to somehow create/mutate class variable(s) of MyClass. Is that possible or do I have to

How do I give a decorator acces to the class of a decorated function

2019-09-04 Thread Antoon Pardon
What I am trying to do is the following. class MyClass (...) : @register def MyFunction(...) ... What I would want is for the register decorator to somehow create/mutate class variable(s) of MyClass. Is that possible or do I have to rethink my approach? -- Antoon Pardon. -- h