Jacob S. wrote:
>> aFuncList=[]
>> def x():
>> print "one"
>> aFuncList.append(x)
>> def x():
>> print "two"
>> aFuncList.append(x)
>> def x():
>> print "three"
>> aFuncList.append(x)
>> for item in aFuncList:
>> item()
>
>
> Okay, for this problem (it can be altered otherwise)
>
> def makefunct(stri):
> def x():
> print stri
> return x
> aFuncList = [makefunct('one'),makefunct('two'),makefunct('three')]
> for item in aFuncList:
> item()
>
> It's shorter, it works and it looks cool.
> Thanks to Jeff Shannon for the backbone of this example.
My intent in showing the above code was not to really print one two
three, but to show that a function doesn't care what it's called.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor