Exec Multiple Lines?

I'd like to dynamically execute multiple lines of indented code from
within a script, but I can't seem to find a suitable function. Exec only
works with unindented code, and execfile only works with files. I
suppose I could write my string to a temporary file and then use
execfile, but that seems like a hack. Is there an easier way? Any help
is appreciated.

Advertisements

On Sat, 12 Jun 2004 02:26:39 -0400, Chris S. wrote:
> I'd like to dynamically execute multiple lines of indented code from
> within a script, but I can't seem to find a suitable function. Exec only
> works with unindented code, and execfile only works with files. I
> suppose I could write my string to a temporary file and then use
> execfile, but that seems like a hack. Is there an easier way? Any help
> is appreciated.

Advertisements

Chris S. wrote:
> I'd like to dynamically execute multiple lines of indented code from
> within a script, but I can't seem to find a suitable function. Exec only
> works with unindented code, and execfile only works with files. I
> suppose I could write my string to a temporary file and then use
> execfile, but that seems like a hack. Is there an easier way? Any help
> is appreciated.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!