printing inside and outside of main() module

K

korean_dave

This allows me to see output:

---begin of try.py
print "Hello World"
--end of try.py

This DOESN'T though...

--begin of try2.py
def main():
return "Hello"
--end of try2.py

Can someone explain why???
 
P

Peter Otten

korean_dave said:
This allows me to see output:

---begin of try.py
print "Hello World"
--end of try.py

This DOESN'T though...

--begin of try2.py
def main():
return "Hello" main() # add this
--end of try2.py

Can someone explain why???

Python doesn't call the main() function; you have to invoke it explicitly.

Peter
 
B

Bruno Desthuilliers

Peter Otten a écrit :
Python doesn't call the main() function; you have to invoke it explicitly.

<OP>
And while we're at it, your main function *returns* a value, but doesn't
*print* anything.
</OP>
 

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
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top