Well, consider this:
you have a file named <mymodule>.py, built like this:
~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/python
def <function>:
....
return <data>
if __name__=="__main__":
print "Unit test"
else:
pass #module imported by another module/script
~~~~~~~~~~~~~~~~~~~~~~
If you type, on command line, >python ./<mymodule>.py
you will see "Unit test" printed to the screen.
if, however you are in another python file and type "import <mymodule>" the
code will, instead, "pass" and nothing will occur.
I hope this helps =)
2008/3/20, Simon Brunning <[EMAIL PROTECTED]>:
>
> On Thu, Mar 20, 2008 at 4:12 PM, Bhagwat Kolde <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I am new to the python and not getting meaning of following line,
> >
> > if __name__ == '__main__':
> > main()
>
> <
> http://www.python.org/doc/faq/programming/#how-do-i-find-the-current-module-name
> >
>
> --
> Cheers,
> Simon B.
> [EMAIL PROTECTED]
> http://www.brunningonline.net/simon/blog/
> GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list