Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Can I find the class of a method in a decorator. Date: Sat, 5 Mar 2016 16:05:11 +0100 Lines: 27 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de kseLZIXfiezyDGbwuIrpTgH25cHBnemHhtVPwFA/eKxQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.048 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'extern': 0.09; 'subject:method': 0.09; 'python': 0.10; 'def': 0.13; 'argument': 0.15; '...)': 0.16; 'received:adsl-dyn.isp.belgacom.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:class': 0.16; 'work,': 0.21; 'suppose': 0.22; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'function': 0.28; 'idea?': 0.29; 'work.': 0.30; 'received:be': 0.30; 'candidate': 0.31; 'anybody': 0.32; 'class': 0.33; 'to:addr:python-list': 0.36; 'method': 0.37; 'subject:the': 0.39; "didn't": 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'obvious': 0.76; 'pardon': 0.84; 'received:195.238': 0.84; 'received:192.168.1.7': 0.91; 'subject:find': 0.91; 'try.': 0.91 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ADBwCA9NpW/zbe9VENUIVMAqsujkuBaTGHPBIBAQEBAQEBhXZVNgIFFgsCCwMCAQIBWAgCt3hnimeELXuFHIlDgjSBOgWXKoFKjCOBTY0tjlUnDoQSihcBAQE User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104097 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: , so that doesn't work. Looking around I didn't find an other obvious candidate to try. Anybody an idea? -- Antoon Pardon