[Tutor] How does this work?
Daniel Yoo
dyoo at WPI.EDU
Wed Feb 7 04:37:16 CET 2007
On Tue, 6 Feb 2007, Daniel Yoo wrote:
>> this is the callee which is saved in tester.py
>> ##############################
>> import sys
>>
>> def main(arg):
>> if arg != []:
>> print"\nArgument is %s" % arg
>>
>> if __name__ == "__main__"":
>> main(sys.argv)
>> ##############################
>
> This is not safe. I would strongly recommend not to do this. There is a
> much simpler way for the caller to be written:
>
> ############################
> import tester
> tester.main([], "argument")
> ############################
>
> Done. No tricks, no eval() or exec() necessary.
... and also not right. *sigh*
Sorry, I meant to write:
#########################
import tester
tester.main(["argument"])
#########################
My apologies!
More information about the Tutor
mailing list