Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34093

amazing scope?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '__name__': 0.07; 'python': 0.09; "'w')": 0.09; 'explanation': 0.09; 'script,': 0.09; 'wrong,': 0.09; 'bug': 0.10; 'def': 0.10; '2.7': 0.13; 'to:name :python-list': 0.15; "'__main__':": 0.16; 'refactored': 0.16; 'somehow,': 0.16; 'module': 0.19; 'looks': 0.26; 'wrote': 0.26; 'message-id:@mail.gmail.com': 0.27; 'declared': 0.29; 'received:209.85.210.174': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; "didn't": 0.36; 'level': 0.37; 'received:209': 0.37; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'below:': 0.71; 'shocking': 0.84; 'working,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=K1LeoNMNbCK0CjpOXVQM6U7BF1oFs487kp2NrS8zy5w=; b=sDltDqoV+GaUWb5J0kBGhqNvNwVosXHtBubw3EG+AMbtegEf6rWLytrRQPqBGNtubd g9Fw1UNX9KH77YpYONg3Kuopvxgt/IIfoB9+oZ7r5G5NF7jDAfbcSf6aH1yt9tiFfHm7 XAw3LHZ4eRqB6DOENvn5etKRdgoVW1cqWOJkIw4hOHXJtAOw9CmjtxxCNxKRM1opb+Zm VQPqnPC88LufvSzJBYX0E0hUdLJ9oHg1UEiU0rYQWS08JME085UJD/dQhz6dfORB1am3 C9u2lXjxv5DL+dyexKgnQNuCTzelvWsnJfDI8LsiaMZ8OCyZVF1/TgtnVzMSGgr74j2j 9eJg==
MIME-Version 1.0
Date Fri, 30 Nov 2012 11:11:28 +0000
Subject amazing scope?
From andrea crotti <andrea.crotti.0@gmail.com>
To python-list <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.380.1354273891.29569.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1354273891 news.xs4all.nl 6933 [2001:888:2000:d::a6]:59233
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34093

Show key headers only | View raw


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 | NextNext in thread | Find similar | Unroll thread


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