Re: Can I find the class of a method in a decorator.

2016-03-05 Thread Steven D'Aprano
On Sun, 6 Mar 2016 03:21 am, Antoon Pardon wrote: > The idea is that some of these methods will be externally available > and others are not. So that I get an external string and can do > something of the following: > > tryout = Tryout() > > st = read_next_cmd() > > if st in tryout.allowed: >

Re: Can I find the class of a method in a decorator.

2016-03-05 Thread Ian Kelly
On Sat, Mar 5, 2016 at 9:21 AM, Antoon Pardon wrote: > Op 05-03-16 om 16:18 schreef Chris Angelico: >> On Sun, Mar 6, 2016 at 2:05 AM, Antoon Pardon >> wrote: >>> Using python 3.4/3.5 >>> >>> Suppose I have the following class: >>> >>> class Tryout: >>> >>> @extern >>> def method(self, ..

Re: Can I find the class of a method in a decorator.

2016-03-05 Thread Peter Otten
Antoon Pardon wrote: > Op 05-03-16 om 16:18 schreef Chris Angelico: >> On Sun, Mar 6, 2016 at 2:05 AM, Antoon Pardon >> wrote: >>> Using python 3.4/3.5 >>> >>> Suppose I have the following class: >>> >>> class Tryout: >>> >>> @extern >>> def method(self, ...) >>> >>> Now how can I have ac

Re: Can I find the class of a method in a decorator.

2016-03-05 Thread Antoon Pardon
Op 05-03-16 om 16:18 schreef Chris Angelico: > On Sun, Mar 6, 2016 at 2:05 AM, Antoon Pardon > wrote: >> Using python 3.4/3.5 >> >> Suppose I have the following class: >> >> class Tryout: >> >> @extern >> def method(self, ...) >> >> Now how can I have access to the Tryout class in >> the e

Re: Can I find the class of a method in a decorator.

2016-03-05 Thread Chris Angelico
On Sun, Mar 6, 2016 at 2:05 AM, Antoon Pardon wrote: > Using python 3.4/3.5 > > Suppose I have the following class: > > class Tryout: > > @extern > def method(self, ...) > > Now how can I have access to the Tryout class in > the extern function when it is called with method > as argument >

Can I find the class of a method in a decorator.

2016-03-05 Thread Antoon Pardon
Using python 3.4/3.5 Suppose I have the following class: class Tryout: @extern def method(self, ...) Now how can I have access to the Tryout class in the extern function when it is called with method as argument def extern(f): the_class = f.__class doesn't work, if I write th