Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34093
| Date | 2012-11-30 11:11 +0000 |
|---|---|
| Subject | amazing scope? |
| From | andrea crotti <andrea.crotti.0@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.380.1354273891.29569.python-list@python.org> (permalink) |
I wrote a script, refactored it and then introducing a bug as below:
def record_things():
out.write("Hello world")
if __name__ == '__main__':
with open('output', 'w') as out:
record_things()
but the shocking thing is that it didn't actually stopped working, it
still works perfectly!
What my explanation might be is that the "out" is declared at module
level somehow,
but that's not really intuitive and looks wrong, and works both on
Python 2.7 and 3.2..
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
amazing scope? andrea crotti <andrea.crotti.0@gmail.com> - 2012-11-30 11:11 +0000
Re: amazing scope? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-30 12:23 +0100
Re: amazing scope? andrea crotti <andrea.crotti.0@gmail.com> - 2012-11-30 16:05 +0000
Re: amazing scope? Chris Angelico <rosuav@gmail.com> - 2012-12-01 03:08 +1100
Re: amazing scope? Dave Angel <d@davea.name> - 2012-11-30 17:57 -0500
csiph-web