Re: run a string as code?
- From: "mtbeedee@xxxxxxxxx" <mtbeedee@xxxxxxxxx>
- Date: 17 Jul 2006 16:08:24 -0700
py_genetic wrote:
How can you make python interpret a string (of py code) as code. For
example if you want a py program to modify itself as it runs. I know
this is an advantage of interpreted languages, how is this done in
python. Thanks.
This might do it...
eval(source[, globals[, locals]]) -> valueprint eval.__doc__
Evaluate the source in the context of globals and locals.
The source may be a string representing a Python expression
or a code object as returned by compile().
The globals must be a dictionary and locals can be any mappping,
defaulting to the current globals and locals.
If only globals is given, locals defaults to it.
.
- Follow-Ups:
- Re: run a string as code?
- From: py_genetic
- Re: run a string as code?
- References:
- run a string as code?
- From: py_genetic
- run a string as code?
- Prev by Date: run a string as code?
- Next by Date: Re: use var to form name of object
- Previous by thread: run a string as code?
- Next by thread: Re: run a string as code?
- Index(es):
Relevant Pages
|