----- Original Message -----
> 2012/11/30 andrea crotti <andrea.crott...@gmail.com>:
> 
> Already changing it to:
> 
> def record_things():
>     out.write("Hello world")
> 
> def main():
>     with open('output', 'w') as out:
>         record_things()
> 
> if __name__ == '__main__':
>     main()
> 
> makes it stops working as expected, so it's really just a corner case
> of using the if __name__ == '__main__'
> which I had never encountered before..

You do realize that 

foo = 5 # define at the module level

if __name__ == '__main__':
    bar = 6 # also at the module level

if True:
    ham = 8 # still at the module level

def func()
    # scope has changed, only at the func level
    jam = 9

Nothing magic about if __name__ == '__main__'

Cheers,

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to