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


Groups > comp.lang.python > #104097

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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Antoon Pardon <antoon.pardon@rece.vub.ac.be>
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 <mailman.225.1457190403.20602.python-list@python.org> (permalink)
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 <antoon.pardon@rece.vub.ac.be>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:104097

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web