doubt regarding main function

P

praba kar

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
function?

if __name__ == '__main__':
test()

What is the advantage of this way calling a
function.

Kindly mail me as early as possible

regards,
Prabahar



________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top