[Tutor] Silly question: Modifying code while the script is running
Michael Langford
mlangford.cs03 at gtalumni.org
Tue Feb 19 01:01:47 CET 2008
import sys
code = """import datetime
print 'This is a pile of arbitrary code to execute'
print sys.argv
print datetime.datetime.now()"""
if len(sys.argv) > 2:
exec(code)
else:
print "Fooless"
--Michael
On Feb 18, 2008 5:17 PM, Scott Wolcott <scottwolcott at gmail.com> 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.
>
> The biggest problem is I'm not sure how to run the external code. Does
> anyone know of good way to do this, or can someone just point me in the
> right direction?
>
> -Scott
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
Michael Langford
Phone: 404-386-0495
Consulting: http://www.RowdyLabs.com
More information about the Tutor
mailing list