code blocks
zipher
dreamingforward at gmail.com
Mon May 11 11:22:02 EDT 2015
On Sunday, May 10, 2015 at 10:32:07 PM UTC-5, Ian wrote:
> On Sun, May 10, 2015 at 7:39 PM, zipher <dreamingforward at 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
More information about the Python-list
mailing list