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


Groups > comp.lang.python > #77670

Re: __qualname__ in python 3.3

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=python.org; s=200901; t=1410094997; bh=t4esOuNrII4LI/XcygO/QQixbqIXlfJ5WYgqvWpXoPk=; h=To:From:Subject:Date:References:From; b=GDTO/5Fz2Dn30MUgBkMAgougbOlM/eTtnytRIk3uK5hgt5nqN+/vcgUGB6lIsBYUm KxHD4yxT4Ujh/g6DCL1W3hBcfT4xW26Lieu3jld80d1ej6NSwK2tfbE2xyRnlR0HJ/ 6nJpHIWmXXBEfzuxo2TzRA/Od8Q+xQ7krBhaWFH4=
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'notice,': 0.07; 'constructor': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; '(none,': 0.16; 'corresponds': 0.16; 'dig': 0.16; 'from:name:antoine pitrou': 0.16; 'message-id:@post.gmane.org': 0.16; 'object).': 0.16; 'received:213.41.240': 0.16; 'received:213.41.240.54': 0.16; 'received:80.91.229.3': 0.16; 'received:charlus.yi.org': 0.16; 'received:plane.gmane.org': 0.16; 'received:yi.org': 0.16; 'subject:3.3': 0.16; 'subject:python': 0.16; 'from:addr:python.org': 0.16; '>>>': 0.22; 'header:User- Agent:1': 0.23; "shouldn't": 0.24; 'second': 0.26; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; '(which': 0.31; 'code': 0.31; "skip:' 10": 0.31; 'writes:': 0.31; 'class': 0.32; 'checked': 0.32; 'skip:- 30': 0.32; 'implemented': 0.33; 'skip:_ 10': 0.34; 'definition': 0.35; 'more,': 0.35; 'test': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; 'hi,': 0.36; 'wrong': 0.37; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'future': 0.60; 'subjectcharset:utf-8': 0.72; 'antoine.': 0.84; 'internally.': 0.84; 'subject::': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Antoine Pitrou <antoine@python.org>
Subject Re: __qualname__ in python 3.3
Date Sun, 7 Sep 2014 13:03:04 +0000 (UTC)
References <540b3293$0$2056$426a74cc@news.free.fr>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host sea.gmane.org
User-Agent Loom/3.14 (http://gmane.org/)
X-Loom-IP 213.41.240.54 (Mozilla/5.0 (X11; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.13847.1410094999.18130.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410094999 news.xs4all.nl 2832 [2001:888:2000:d::a6]:51853
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77670

Show key headers only | View raw


Hi,

ISE Development <isenntp <at> gmail.com> writes:
> 'code' object     'function' object
> ----------------  ------------------------------------
> co_name: test     __qualname__: test
> co_name: T        __qualname__: T
> co_name: method   __qualname__: test.<locals>.T.method
> 
> The second call corresponds to the class definition and not the call to the 
> constructor (which is in fact a call to 'object.__init__', a C function 
> hence not traced as a 'call' event - I checked this by disassembling the 
> code object).

There's nothing wrong here. That's just the way things are implemented
internally. This may change in the future without prior notice, so
you shouldn't rely on it.

If you want to dig more, you have to look at how the hidden function ("T")
works:

>>> def f():
...   class T: pass
... 
>>> f.__code__.co_consts
(None, <code object T at 0x7f4d9d0f4a00, file "<stdin>", line 2>, 'T')
>>> dis.dis(f.__code__.co_consts[1])
  2           0 LOAD_NAME                0 (__name__)
              3 STORE_NAME               1 (__module__)
              6 LOAD_CONST               0 ('f.<locals>.T')
              9 STORE_NAME               2 (__qualname__)
             12 LOAD_CONST               1 (None)
             15 RETURN_VALUE

Regards

Antoine.

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


Thread

__qualname__ in python 3.3 ISE Development <isenntp@gmail.com> - 2014-09-06 18:13 +0200
  Re: __qualname__ in python 3.3 Peter Otten <__peter__@web.de> - 2014-09-06 18:47 +0200
    Re: __qualname__ in python 3.3 ISE Development <isenntp@gmail.com> - 2014-09-06 19:09 +0200
      Re: __qualname__ in python 3.3 Peter Otten <__peter__@web.de> - 2014-09-06 20:11 +0200
  Re: __qualname__ in python 3.3 Antoine Pitrou <antoine@python.org> - 2014-09-07 13:03 +0000
    Re: __qualname__ in python 3.3 ISE Development <isenntp@gmail.com> - 2014-09-08 00:25 +0200

csiph-web