if you run in the same file there is no difference.
Block under "__main__" will be executed if you run that file only but
if you import that file from another file, then if you don't put your
code inside "__main__" your code it will be executed (this is not what
you want).
Example:
You have 1 fi
Dear All,
I want to know the difference between calling
a function directly and through main function
compose()
if __name__ == __main__:
compose()
Yahoo! India Matrimony: Find your life partner online
Go to: htt
if __name__ == '__main__':
test()
What is the advantage of this way calling a
function.
For example, you can have a python script that has this function:
def search(keywords,engine='www.google.com')
At the end of the script, you can have this:
if __name__ == '__main__':
import sys
Dear All,
I have doubt regarding main function in
Python. In Python we can create a function
and we can call a function directly.
(eg:)
def test():
print 'main function test'
I can call this function the following way
eg) test()
So why we need the below way of calling a
fun