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


Groups > comp.lang.python > #50115

Re: Default scope of variables

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.097
X-Spam-Evidence '*H*': 0.81; '*S*': 0.00; 'spelled': 0.09; 'language,': 0.12; 'language.': 0.14; 'another?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nesting': 0.16; 'nightmare': 0.16; 'programmer,': 0.16; 'similarly,': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'normally': 0.19; "python's": 0.19; 'mon,': 0.24; 'pass': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'wonder': 0.29; 'database,': 0.30; 'moved': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'lines': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; 'another': 0.32; 'checking': 0.33; 'sense': 0.34; "can't": 0.35; 'transaction': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'two': 0.37; 'level': 0.37; 'sometimes': 0.38; 'same.': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'track': 0.38; 'rather': 0.38; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'around.': 0.60; 'most': 0.60; 'first': 0.61; 'name': 0.63; 'more': 0.64; 'different': 0.65; 'design.': 0.68; 'jul': 0.74; 'obvious': 0.74; 'goal': 0.75; '"one': 0.84; 'everywhere.': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=6Z9e4sexuR1z9V+kyu5L25RD8Zc65Ps8F/ZQZc9g74k=; b=o6DrMVaIsl2tfH+GhPYW9YVX/wnVKoEdXAEMgSgBv2pwARTUIRKCN/bSY13JkdqO// ZEPc16bq+pt0mZ0pPsARuPSeKPL9OfTj7ykwPragbaybDSwWiPkxqCur+78FdCq+PFUH RbOKitvGV1COy9dqa03T6gXg2Rzs/s6VpvQiTk8QG5gLKeTA3OtqYpgHMDw+wXlkF/XM gG2IofjHag08LsPDSX01JJ88S24jnHKiWaK9Y0YUn3D3m7vLe+jap0G6+LoZuTEopqxG 1jyuQ1gGvChOevvdtXzUGc424012STanUl0kTLEsJh4PmXo/UxO20yd2LTBQFFuJaET4 gp9Q==
MIME-Version 1.0
X-Received by 10.58.187.4 with SMTP id fo4mr12795915vec.55.1373253097506; Sun, 07 Jul 2013 20:11:37 -0700 (PDT)
In-Reply-To <51da2294$0$6512$c3e8da3$5496439d@news.astraweb.com>
References <51d4eb9c$0$29999$c3e8da3$5496439d@news.astraweb.com> <mailman.4200.1372910878.3114.python-list@python.org> <51d508ed$0$6512$c3e8da3$5496439d@news.astraweb.com> <mailman.4208.1372916885.3114.python-list@python.org> <51d5a504$0$29999$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmpgmABYwn0xB4T-9VbYMP=8JfpRcy8TPSerzyGvzPbMmA@mail.gmail.com> <alpine.DEB.2.02.1307070759350.18702@gilgamesh> <CAPTjJmrTXxhpNm-e-_H_xDBe0q9qNuJnLmQpYdhXOHmiWpCZYw@mail.gmail.com> <51D99CBC.40606@stoneleaf.us> <mailman.4361.1373244492.3114.python-list@python.org> <51da2294$0$6512$c3e8da3$5496439d@news.astraweb.com>
Date Mon, 8 Jul 2013 13:11:37 +1000
Subject Re: Default scope of variables
From Chris Angelico <rosuav@gmail.com>
To 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.4363.1373253106.3114.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373253106 news.xs4all.nl 15936 [2001:888:2000:d::a6]:57092
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50115

Show key headers only | View raw


On Mon, Jul 8, 2013 at 12:23 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Mon, 08 Jul 2013 10:48:03 +1000, Chris Angelico wrote:
> [...]
>> That means that I, as programmer, have to keep track of the nesting
>> level of subtransactions. Extremely ugly. A line of code can't be moved
>> around without first checking which transaction object to work with.
>
> I feel your pain, but I wonder why we sometimes accept "a line of code
> can't be moved around" as an issue to be solved by the language. After
> all, in general most lines of code can't be moved around.

It's not something to be solved by the language, but it's often
something to be solved by the program's design. Two lines of code that
achieve the same goal should normally look the same. This is why
Python's policy is "one obvious way to do something" rather than
"spell it five different ways in the same file to make a nightmare for
other people coming after you". Why should database queries be spelled
"trans1.query()" in one place, and "trans2.query()" in another?
Similarly, if I want to call another function and that function needs
to use the database, why should I pass it trans3 and have that come
out as trans1 on the other side? Unnecessarily confusing. Makes much
more sense to use the same name everywhere.

ChrisA

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


Thread

Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-04 03:27 +0000
  Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-04 14:07 +1000
    Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-04 05:32 +0000
      Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-04 15:47 +1000
        Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-04 16:38 +0000
          Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-05 02:58 +1000
          Re: Default scope of variables Wayne Werner <wayne@waynewerner.com> - 2013-07-07 08:13 -0500
          Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-07 23:43 +1000
            Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-07 16:03 +0000
              Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-08 10:46 +1000
            Re: Default scope of variables alex23 <wuwei23@gmail.com> - 2013-07-09 14:52 +1000
              Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-09 15:07 +1000
                Re: Default scope of variables alex23 <wuwei23@gmail.com> - 2013-07-09 16:08 +1000
                Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-09 16:13 +1000
                Re: Default scope of variables "Frank Millman" <frank@chagford.com> - 2013-07-09 09:35 +0200
                Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-09 17:45 +1000
                Re: Default scope of variables Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-09 01:56 -0600
                Re: Default scope of variables "Frank Millman" <frank@chagford.com> - 2013-07-09 10:22 +0200
                Re: Default scope of variables "Frank Millman" <frank@chagford.com> - 2013-07-09 10:38 +0200
                Re: Default scope of variables Ethan Furman <ethan@stoneleaf.us> - 2013-07-09 09:07 -0700
                Re: Default scope of variables Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-09 10:44 -0600
                Re: Default scope of variables Ethan Furman <ethan@stoneleaf.us> - 2013-07-09 10:23 -0700
                Re: Default scope of variables Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-09 12:41 -0600
                Re: Default scope of variables Ethan Furman <ethan@stoneleaf.us> - 2013-07-09 12:19 -0700
                Re: Default scope of variables "Frank Millman" <frank@chagford.com> - 2013-07-10 07:54 +0200
                Re: Default scope of variables Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-10 09:42 -0600
                Re: Default scope of variables Ethan Furman <ethan@stoneleaf.us> - 2013-07-10 08:29 -0700
                Re: Default scope of variables "Frank Millman" <frank@chagford.com> - 2013-07-11 07:52 +0200
          Re: Default scope of variables Ethan Furman <ethan@stoneleaf.us> - 2013-07-07 09:52 -0700
          Re: Default scope of variables Ethan Furman <ethan@stoneleaf.us> - 2013-07-07 11:59 -0700
          Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-08 10:48 +1000
            Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-08 02:23 +0000
              Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-08 13:11 +1000
                Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-08 05:00 +0000
                Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-08 15:14 +1000
      Re: Default scope of variables Peter Otten <__peter__@web.de> - 2013-07-04 08:48 +0200
      Re: Default scope of variables Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-04 01:12 -0600
      Re: Default scope of variables Dave Angel <davea@davea.name> - 2013-07-04 03:06 -0400
        Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-04 15:52 +0000
        Re: Default scope of variables Rotwang <sg552@hotmail.co.uk> - 2013-07-04 17:54 +0100
          Re: Default scope of variables Peter Otten <__peter__@web.de> - 2013-07-04 20:36 +0200
          Re: Default scope of variables Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-05 01:04 +0100
          Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-05 01:24 +0000
            Re: Default scope of variables Dave Angel <davea@davea.name> - 2013-07-04 22:03 -0400
            Re: Default scope of variables Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-05 03:29 +0100
            Re: Default scope of variables Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-05 03:27 +0100
            Re: Default scope of variables Rotwang <sg552@hotmail.co.uk> - 2013-07-05 07:28 +0100
        Re: Default scope of variables Neil Cerutti <neilc@norwich.edu> - 2013-07-05 13:24 +0000
          Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-05 23:43 +1000
            Re: Default scope of variables Neil Cerutti <neilc@norwich.edu> - 2013-07-05 15:36 +0000
          Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-07 16:08 +0000
            Re: Default scope of variables Neil Cerutti <neilc@norwich.edu> - 2013-07-08 11:54 +0000
              Re: Default scope of variables Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-08 14:14 +0100
      Re: Default scope of variables Lele Gaifax <lele@metapensiero.it> - 2013-07-04 14:43 +0200
      Re: Default scope of variables Wayne Werner <wayne@waynewerner.com> - 2013-07-04 10:45 -0500
  Re: Default scope of variables Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-04 05:30 +0100
    Re: Default scope of variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-04 05:45 +0000
  Re: Default scope of variables Chris Angelico <rosuav@gmail.com> - 2013-07-04 14:36 +1000
  Re: Default scope of variables Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-04 06:09 +0100
  Re: Default scope of variables Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-08 17:58 +0100

csiph-web