Meador Inge <mead...@gmail.com> added the comment: On Wed, Dec 28, 2011 at 3:11 PM, Eric Snow <rep...@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>' ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13672> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com