[Tutor] Silly question: Modifying code while the script is running

Luke Paireepinart rabidpoobear at gmail.com
Wed Feb 20 15:38:15 CET 2008

Scott Wolcott wrote:
> Okay, I've got this ircbot that i wrote in python, and while we were 
> all making Terminator jokes, it occurred to me that it would actually 
> be reletively easy to have redqueen (that's the bot) write code into 
> another file. Then you just have to specify the file and import the 
> code and run it. It sounds possible, but there are a couple of things 
> i'm not sure how to do.
If you have your script write properly-formatted python to a .py file, 
you can just import() the script it writes, and reload() it whenever you 
make changes.  imported scripts are automatically executed.  (I assume 
on reload they are also, but you should check this.)
This is considered taboo unless it's very necessary, but I hope you have 
fun anyway.
Let me know how it goes.

More information about the Tutor mailing list