Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Parsing Python code with a Python Program

Reply
Thread Tools

Parsing Python code with a Python Program

 
 
pgw
Guest
Posts: n/a
 
      08-22-2004
Hello,

I would like to pass strings to a Python
application and have them executed as though
they were lines of code.

Is 'exec()' the function that I am looking for
and/or is there an example of this somewhere?

Thanks,

Seaweed

 
Reply With Quote
 
 
 
 
pw
Guest
Posts: n/a
 
      08-23-2004
Hello,

I had my quotes wrong is all.

EXAMPLE:

exec 'print "Hello"'

OR:

s = 'print "hello"'

exec s

Thanks anyway,

Seaweed






pgw wrote:
> Hello,
>
> I would like to pass strings to a Python
> application and have them executed as though
> they were lines of code.
>
> Is 'exec()' the function that I am looking for
> and/or is there an example of this somewhere?
>
> Thanks,
>
> Seaweed
>


 
Reply With Quote
 
 
 
 
Michael Hudson
Guest
Posts: n/a
 
      08-23-2004
pgw <(E-Mail Removed)> writes:

> Hello,
>
> I would like to pass strings to a Python
> application and have them executed as though
> they were lines of code.
>
> Is 'exec()' the function that I am looking for
> and/or is there an example of this somewhere?


Well, it's a statement, not a function, but yes, that's what you're
looking for.

Cheers,
mwh

--
Well, you pretty much need Microsoft stuff to get misbehaviours
bad enough to actually tear the time-space continuum. Luckily
for you, MS Internet Explorer is available for Solaris.
-- Calle Dybedahl, alt.sysadmin.recovery
 
Reply With Quote
 
Ivo Woltring
Guest
Posts: n/a
 
      10-22-2004
Well you can also generate code into a specific file name and then import
the file and execute the generated code by reference to file.function...

goodluck
Ivo

"Michael Hudson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> pgw <(E-Mail Removed)> writes:
>
> > Hello,
> >
> > I would like to pass strings to a Python
> > application and have them executed as though
> > they were lines of code.
> >
> > Is 'exec()' the function that I am looking for
> > and/or is there an example of this somewhere?

>
> Well, it's a statement, not a function, but yes, that's what you're
> looking for.
>
> Cheers,
> mwh
>
> --
> Well, you pretty much need Microsoft stuff to get misbehaviours
> bad enough to actually tear the time-space continuum. Luckily
> for you, MS Internet Explorer is available for Solaris.
> -- Calle Dybedahl, alt.sysadmin.recovery



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie code review of parsing program Please len Python 8 11-17-2008 04:04 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 09:01 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 08:58 PM
SAX Parsing - Weird results when parsing content between tags. Naren XML 0 05-11-2004 07:25 PM
Perl expression for parsing CSV (ignoring parsing commas when in double quotes) GIMME Perl 2 02-11-2004 05:40 PM



Advertisments