Execute commands from file

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Wed May 16 09:22:34 EDT 2007


In <1179320782.594398.67980 at u30g2000hsc.googlegroups.com>, tmp123 wrote:

> We have very big files with python commands (more or less, 500000
> commands each file).
> 
> It is possible to execute them command by command, like if the
> commands was typed one after the other in a interactive session?

Take a look at the `code` module in the standard library:

In [31]: code?
Type:           module
Base Class:     <type 'module'>
String Form:    <module 'code' from '/usr/lib/python2.4/code.pyc'>
Namespace:      Interactive
File:           /usr/lib/python2.4/code.py
Docstring:
    Utilities needed to emulate Python's interactive interpreter.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list