2008/4/11, Evan <[EMAIL PROTECTED]>: > > > Hope this hasn't been posted hundreds of times. I'm new for this. > > Before using python for this kind of script, I was using TCL to write > down a "command line based" interactive program. it likes a "tclsh", > or "python" command, after that, you can work under a prompt, for > example, " - >> ", and then you can execute any commands what you > defined in script. > > Now, in python, are there any common way(class) to finish this work? > or does anybody has a example to do that?
I think the simplest way is using the InteractiveConsole class from the 'code' module. It shows a prompt, reads the commands you type and checks and executes them. Doc here: http://docs.python.org/lib/module-code.html This way the TCL part could be not necessary, though. If you need some special functionality (e.g., storing the commands you type), you can subclass it easily. Thanks, > Evan > Hope it helps :)
-- http://mail.python.org/mailman/listinfo/python-list