[issue6507] Enhance dis.dis to autocompile codestrings

Nick Coghlan report at bugs.python.org
Sat Jul 18 15:48:55 CEST 2009


Nick Coghlan <ncoghlan at gmail.com> added the comment:

As per Georg's suggestion, a better approach would look like:

from dis import dis
def dis_str(source):
  try:
    c = compile(source, '', 'eval')
  except SyntaxError:
    c = compile(source, '', 'exec')
  return dis(c)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6507>
_______________________________________


More information about the Python-bugs-list mailing list