Message90647
Copying my suggestion (minus examples) over from the python-ideas thread:
We could define it as trying the three modes in order (first 'eval',
then 'single', then 'exec') moving on to the next option if it raises
syntax error:
from dis import dis
def dis_str(source):
modes = ('eval', 'single', 'exec')
for mode in modes:
try:
c = compile(source, '', mode)
break
except SyntaxError:
if mode is modes[-1]:
raise
return dis(c) |
|
Date |
User |
Action |
Args |
2009-07-17 22:57:55 | ncoghlan | set | recipients:
+ ncoghlan, terry.reedy |
2009-07-17 22:57:54 | ncoghlan | set | messageid: <1247871474.95.0.158161013614.issue6507@psf.upfronthosting.co.za> |
2009-07-17 22:57:53 | ncoghlan | link | issue6507 messages |
2009-07-17 22:57:53 | ncoghlan | create | |
|