Hi Gurus,
I am new python programming.. I see many programs
if __name__ == '__main__':
when I check __name__ always eq __main__.
what purpose use these structure.. please guide me..
-Ganesh
--
Did I learn something today? If not, I wasted it.
___
On 20 May 2011 12:09, Ganesh Kumar bugcy...@gmail.com wrote:
Hi Gurus,
I am new python programming.. I see many programs
if __name__ == '__main__':
when I check __name__ always eq __main__.
what purpose use these structure.. please guide me..
-Ganesh
Here you go:
If the module is run as a program, then the __name__ is assigned the value
__main__ .
If the module is imported, then the value is not assigned.
Please see here -
http://stackoverflow.com/questions/419163/what-does-if-name-main-do
On 2011/05/20 01:09 PM, Ganesh Kumar wrote:
Hi Gurus,
I am new python programming.. I see many programs
if __name__ == '__main__':
when I check __name__ always eq __main__.
what purpose use these structure.. please guide me..
-Ganesh
If you execute the script directly ie. python script.py
On 2011/05/20 01:29 PM, Christian Witts wrote:
On 2011/05/20 01:09 PM, Ganesh Kumar wrote:
Hi Gurus,
I am new python programming.. I see many programs
if __name__ == '__main__':
when I check __name__ always eq __main__.
what purpose use these structure.. please guide me..
-Ganesh
If you
Hi, Ganesh !
An important use of this feature is the so-called modular testing, aka
unit testing. I mean: that way you can provide functionality in your
module to test it independently of any application it may be contained
in.
Unit testing in general is easier and quicker to do than to test the
Hi, Ganesh !
Adding to what Christian already stated, i'd like to tell you that an
important use of this feature is the so-called modular testing, aka
unit testing. I mean: that way you can provide functionality in your
module to test it independently of any application it may be contained
in.