homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author meador.inge
Recipients Arfrever, eric.snow, jcea, meador.inge, pitrou
Date 2012年01月24日.19:41:25
SpamBayes Score 0.00014624107
Marked as misclassified No
Message-id <CAK1Qooo_Ct4OJRJz=PswVF5ObbaR11arKUc4uiOKgZRCqWeVcA@mail.gmail.com>
In-reply-to <1325106685.0.0.411832471872.issue13672@psf.upfronthosting.co.za>
Content
On Wed, Dec 28, 2011 at 3:11 PM, Eric Snow <report@bugs.python.org> wrote:
> One sticky point is that there isn't a guarantee of one-to-one between function object and code object. A code object could be bound to several
> different functions as happens with function definitions (particularly lambdas) inside comprehensions.
>
> Also, if a code object is not associated with a function, i.e. one generated by exec, what should the qualname for the code object be? How
> about, in CPython, the code objects created for classes and modules?
We already these issues with 'co_name', though. These cases can be
treated the same as they are for 'co_name':
'<listcomp>'
>>> compile('[i for i in [1, 2]]', '<foo>', 'exec').co_consts[0].co_qualname
'<listcomp>'
>>> compile('class T: pass', '<foo>', 'exec').co_consts[0].co_qualname
'T'
>>> compile('class T: pass', '<foo>', 'exec').co_consts[0].co_name
'T'
>>> compile('a = 12', '<foo>', 'exec').co_name
'<module>'
>>> compile('a = 12', '<foo>', 'exec').co_qualname
'<module>'
>>> compile('lambda x: x', '<foo>', 'exec').co_consts[0].co_qualname
'<lambda>'
>>> compile('lambda x: x', '<foo>', 'exec').co_consts[0].co_name
'<lambda>'
History
Date User Action Args
2012年01月24日 19:41:26meador.ingesetrecipients: + meador.inge, jcea, pitrou, Arfrever, eric.snow
2012年01月24日 19:41:25meador.ingelinkissue13672 messages
2012年01月24日 19:41:25meador.ingecreate

AltStyle によって変換されたページ (->オリジナル) /