Help me on function definition

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Mar 29 03:19:09 CET 2008


Oh, I forgot to mention...

On Sat, 29 Mar 2008 01:47:21 +0000, aeneng wrote:

> if __name__=="__main__":
...
> 	print "file name is %s" %__name__


This doesn't do what you expect it to do. You've already established that 
__name__ is equal to "__main__", so you might as well change that line to:

    print "file name is not actually __main__"

What you want is:

    print "file name is %s" % __file__



-- 
Steven



More information about the Python-list mailing list