How to exec() a string like interactive python does?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Jun 5 19:31:05 EDT 2012
On Wed, 06 Jun 2012 00:12:00 +0200, News123 wrote:
> If I start Python in interactive mode, and I yype the commands,
> 'a=3', 'a', 'print a'
>
>
> Then the output would look like:
> >>> a = 3
> >>> a
> 3
> >>> print a
> 3
>
>
> Now within an application I'd like to achieve exactly this behaviour
Before you reinvent the wheel, see the cmd and code modules.
http://docs.python.org/library/cmd.html
http://docs.python.org/library/code.html
--
Steven
More information about the Python-list
mailing list