[Python-ideas] Augment dis.dis to autocompile strings
Nick Coghlan
ncoghlan at gmail.com
Sat Jul 18 15:47:57 CEST 2009
Georg Brandl wrote:
> I don't think using "single" makes sense here; trying "eval" can't hurt,
> though.
Agreed. Only having the two modes to worry about greatly simplifies the
code as well:
from dis import dis
def dis_str(source):
try:
c = compile(source, '', 'eval')
except SyntaxError:
c = compile(source, '', 'exec')
return dis(c)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
More information about the Python-ideas
mailing list