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
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
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
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
> 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
> 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
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"
> ##
>
>
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(
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:
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
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
> 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
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
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
14 matches
Mail list logo