On Sunday, May 10, 2015 at 10:32:07 PM UTC-5, Ian wrote:
> On Sun, May 10, 2015 at 7:39 PM, zipher <dreamingforw...@gmail.com> wrote:
> > Similarly, you'd want:
> >
> >>>> encode(codestr)
> >
> > to instantiate all objects in the codestr.  You can't do this with eval, 
> > because it doesn't allow assignment (eval(n=2) returns "InvalidSyntax").
> 
> Is exec what you're looking for?
> 
> >>> exec('n = 2')
> >>> print(n)
> 2

Ah, yeah, I guess that does it.  But (shame) it looks like you've gone past the 
BDFL.  Try:

>>> help(exec)
            ^
SyntaxError: invalid syntax 

Better

Mark
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to