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


Groups > comp.lang.python > #6565

Re: scope of function parameters

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'compiler': 0.07; 'subject:parameters': 0.09; 'pm,': 0.10; 'debugging': 0.14; 'wrote:': 0.14; '*after*': 0.16; 'angelico': 0.16; 'confusing.': 0.16; 'subject:function': 0.16; 'compile': 0.19; 'cheers,': 0.19; 'guess': 0.19; 'header:In-Reply-To:1': 0.21; 'figure': 0.21; 'variable': 0.21; 'received:209.85.161.46': 0.23; 'received:mail- fx0-f46.google.com': 0.23; 'received:209.85.161': 0.26; 'message- id:@mail.gmail.com': 0.28; 'bound': 0.29; 'consequence': 0.30; 'sun,': 0.30; 'it.': 0.31; 'print': 0.31; 'determined': 0.32; 'to:addr:python-list': 0.33; 'error': 0.33; 'chris': 0.34; 'rule': 0.34; 'quite': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; 'involving': 0.37; 'could': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'unless': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'storage': 0.66; 'making': 0.67; 'functioned': 0.84; 'road.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=Ch8RbO8rWddT//rOjAwB92o25MR2Y6hAd0Ig8Ox+/qc=; b=VAp8Ms6OYKTSbkYxAgpxuTF79afrqJFYS+sZiMIvbgKom3En8MDcI4IFWx3ONupz9E Bl+kOEbWk2PLkTgCVm8ORE95xc4qU6tWK+iDm7heZWlZc/D3czeFpgU3UN/gOP3O+3dR 7h5OgYAFdeAeW/Kk/Q9drQg10fm276FQoVYA4=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=FV8fr5R8jckzwWDk/SSzZeEutxZDY3gLbBKKuiSHcNuoje86YruIBD0TQaQgDUYkp2 /NYczLgUjRG3T1Q9tufBeNUbD/ejV9IVPfo7umtr86K3BMf2BorXti36MIa7JMgVTYF/ CK6SXcOat0d0Iu74cEyzv/h6Tnf4tiNlwYIjk=
MIME-Version 1.0
In-Reply-To <BANLkTikL=mf+XfXincqHn--WsXaowEpyng@mail.gmail.com>
References <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <mailman.2217.1306662671.9059.python-list@python.org> <4de24045$0$29996$c3e8da3$5496439d@news.astraweb.com> <BANLkTinK=dHCbocURD2+s5uvdonBkS+uFQ@mail.gmail.com> <BANLkTimWP+jP0s5DsBaFbv6LV5OTYA8hQw@mail.gmail.com> <BANLkTikL=mf+XfXincqHn--WsXaowEpyng@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Sun, 29 May 2011 13:12:16 -0600
Subject Re: scope of function parameters
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.2234.1306696367.9059.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 82.94.164.166
X-Trace 1306696368 news.xs4all.nl 49039 [::ffff:82.94.164.166]:54093
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6565

Show key headers only | View raw


On Sun, May 29, 2011 at 12:38 PM, Chris Angelico <rosuav@gmail.com> wrote:
> I thought it basically functioned top-down. You get a different error
> on the print line if there's a "bar = 42" *after* it. This could make
> debugging quite confusing.
>
> Guess it's just one of the consequences of eschewing variable
> declarations. Sure it's easier, but there's complications down the
> road.

It's also a consequence of local variable access being optimized with
different bytecode: the type of storage has to be determined at
compile time.  The compiler could in principle figure out that "bar"
cannot be bound at that point and make it a global reference, but it
is easy to concoct situations involving loops or conditionals where
the storage cannot be determined at compile time, and so the compiler
follows the simple rule of making everything local unless it's never
assigned.

Cheers,
Ian

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: scope of function parameters Wolfgang Rohdewald <wolfgang@rohdewald.de> - 2011-05-29 11:47 +0200
  Re: scope of function parameters Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 12:47 +0000
    Re: scope of function parameters Chris Angelico <rosuav@gmail.com> - 2011-05-30 03:53 +1000
      Re: scope of function parameters Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 18:28 +0000
    Re: scope of function parameters Chris Rebert <clp2@rebertia.com> - 2011-05-29 11:01 -0700
    Re: scope of function parameters Chris Angelico <rosuav@gmail.com> - 2011-05-30 04:38 +1000
      Re: scope of function parameters Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 18:53 +0000
        Re: scope of function parameters Chris Angelico <rosuav@gmail.com> - 2011-05-30 05:20 +1000
    Re: scope of function parameters Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-29 13:12 -0600

csiph-web