[Python-ideas] Augment dis.dis to autocompile strings

Steven D'Aprano steve at pearwood.info
Fri Jul 17 04:32:21 CEST 2009


On Fri, 17 Jul 2009 04:35:40 am Terry Reedy wrote:

> Proposal: if the input is a string, do the above (do what I mean)
> instead of raising
> TypeError: don't know how to disassemble str objects
>
> Any negatives before I submit a feature request?

+1 on the idea, but how do you determine which of the following are 
required?

compile('x+1', '', 'eval')
compile('x = x+1', '', 'single')
compile('while x < 42: x += 1', '', 'exec')


Or do you just assume 'exec'?


-- 
Steven D'Aprano



More information about the Python-ideas mailing list