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

2008-02-20 Thread Luke Paireepinart
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 im

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

2008-02-18 Thread Michael Langford
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 <[EMAIL PROTECTED]> wrote: > Okay, I've

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

2008-02-18 Thread Scott Wolcott
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 sou

Re: [Tutor] silly question

2004-12-29 Thread jasonchild
awesome. thanks for the advice! >> how do I change global variables within a function: >> > > by declaring them as global. > See my tutorial topic: "Whats in a Name?" for a discussion of this. > >> ## >> VAR = "TEST" >> >> def m(): >> VAR="no test" > > creates a

Re: [Tutor] silly question

2004-12-23 Thread Alan Gauld
> how do I change global variables within a function: > by declaring them as global. See my tutorial topic: "Whats in a Name?" for a discussion of this. > ## > VAR = "TEST" > > def m(): > VAR="no test" creates a new variable insidethe function. def m(): g

Re: [Tutor] silly question

2004-12-23 Thread Alan Gauld
> sorry everyone, I figured it out on my own ;) So having made it a tutor topic, please close the discussion by telling us what was wrong. That way the rest of us don't spend the rest of the day worrying about it, saying "I wonder what Jason did wrong?" :-) Sorry if I appear to nag but its how th

Re: [Tutor] silly question

2004-12-22 Thread Orri Ganel
On Wed, 22 Dec 2004 17:52:53 -0700, Jason Child <[EMAIL PROTECTED]> wrote: > Ok, I guess my question (now) is: > > how do I change global variables within a function: > > ## > VAR = "TEST" > > def m(): > VAR="no test" > ## > >

Re: [Tutor] silly question

2004-12-22 Thread Jason Child
Ok, I guess my question (now) is: how do I change global variables within a function: ## VAR = "TEST" def m(): VAR="no test" ## when I do this (from the interactive editor): ## >>>print VAR TEST >>>m(

Re: [Tutor] silly question

2004-12-22 Thread Roger Merchberger
Rumor has it that Jason Child may have mentioned these words: ## I've got a silly question. ### P1 = "prefix1" P2 = "prefix2" def my_func(list, items): s = 0 out = "" for i in range(len(list)): if s == 0: p = P1 s = 1 else:

Re: [Tutor] silly question

2004-12-22 Thread Jason Child
sorry everyone, I figured it out on my own ;) Jason Child wrote: Alan Gauld wrote: oops, I forgot to add the s = 1 and s=0 lines to the example code i posted... OK, To save us guessing, why don't you post it with the s=1/0 and also the actual output pattern you get? Seeing the error is a v

Re: [Tutor] silly question

2004-12-22 Thread Jason Child
Alan Gauld wrote: oops, I forgot to add the s = 1 and s=0 lines to the example code i posted... OK, To save us guessing, why don't you post it with the s=1/0 and also the actual output pattern you get? Seeing the error is a very powerful technique for guessing what may be

Re: [Tutor] silly question

2004-12-22 Thread Alan Gauld
> oops, I forgot to add the s = 1 and s=0 lines to the example code i > posted... OK, To save us guessing, why don't you post it with the s=1/0 and also the actual output pattern you get? Seeing the error is a very powerful technique for guessing what may be at fault. A second hand description

Re: [Tutor] silly question

2004-12-22 Thread Jason Child
Jason Child wrote: I've got a silly question. ### P1 = "prefix1" P2 = "prefix2" def my_func(list, items): s = 0 out = "" for i in range(len(list)): if s == 0: p = P1 else: p = P2 for j in range(len(items)): out += p

[Tutor] silly question

2004-12-22 Thread Jason Child
I've got a silly question. ### P1 = "prefix1" P2 = "prefix2" def my_func(list, items): s = 0 out = "" for i in range(len(list)): if s == 0: p = P1 else: p = P2 for j in range(len(items)): out += p +items[j] return