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


Groups > comp.lang.python > #104097 > unrolled thread

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

Started byAntoon Pardon <antoon.pardon@rece.vub.ac.be>
First post2016-03-05 16:05 +0100
Last post2016-03-05 16:05 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Can I find the class of a method in a decorator. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-05 16:05 +0100

#104097 — Can I find the class of a method in a decorator.

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2016-03-05 16:05 +0100
SubjectCan I find the class of a method in a decorator.
Message-ID<mailman.225.1457190403.20602.python-list@python.org>
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 the following

def extern(f)
    print(f.__class__)

the result is: <class 'function'>, so that doesn't work.
Looking around I didn't find an other obvious candidate
to try. Anybody an idea?

-- 
Antoon Pardon

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web