Message151922
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>' |
|
Date |
User |
Action |
Args |
2012-01-24 19:41:26 | meador.inge | set | recipients:
+ meador.inge, jcea, pitrou, Arfrever, eric.snow |
2012-01-24 19:41:25 | meador.inge | link | issue13672 messages |
2012-01-24 19:41:25 | meador.inge | create | |
|