printing inside and outside of main() module

Peter Otten __peter__ at web.de
Wed Apr 30 12:18:03 EDT 2008


Bruno Desthuilliers wrote:

> Peter Otten a écrit :
>> korean_dave wrote:
>> 
>>> 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.
> 
> <OP>
> And while we're at it, your main function *returns* a value, but doesn't
> *print* anything.
> </OP>

Ouch!



More information about the Python-list mailing list