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


Groups > comp.lang.python > #49923

Re: Default scope of variables

Path csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'elif': 0.05; 'represents': 0.05; 'sys': 0.07; 'categories.': 0.09; 'pep': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'def': 0.12; 'collections': 0.16; 'defaultdict': 0.16; 'identifier.': 0.16; 'identifiers': 0.16; 'itertools': 0.16; 'non-ascii': 0.16; 'set()': 0.16; 'url:peps': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'url:dev': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'correct': 0.29; 'character': 0.29; 'quickly': 0.29; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; "i'm": 0.30; 'code': 0.31; '+0100,': 0.31; "d'aprano": 0.31; 'ones.': 0.31; 'steven': 0.31; 'up:': 0.31; 'stuff': 0.32; 'url:python': 0.33; 'there,': 0.34; 'skip:s 30': 0.35; 'skip:u 20': 0.35; 'something': 0.35; 'definition': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'method': 0.36; 'url:org': 0.36; 'starting': 0.37; 'expected': 0.38; 'pm,': 0.38; 'skip:x 10': 0.40; 'above,': 0.60; 'chain': 0.60; 'dave': 0.60; 'url:3': 0.61; 'july': 0.63; 'more': 0.64; 'worth': 0.66; 'sample': 0.67; 'jul': 0.74; 'describes': 0.84; 'url:reference': 0.84; 'angel': 0.91; '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:from:date:message-id:subject:to :cc:content-type; bh=z/dFkUzJV2ToNh7AFkiTzkiiAQreB7ZIpyrBsAWZtg8=; b=fZ/GtxHNts8LPsyHo2SVfl4g/fLazDtW6gkCpH/DOLk+8BQxwhsve+I1k7zCOzsI0N DUE8rU053tbAXT+T08EfSAzvAbHnumD7yGMzgs/LALJH6n5yRtgIgSAhS3Xlk7+qDrln Qp1vCYPPv/QCA9oXuybq3PDY2kA/PWy1/k5ZsY/9LlV7xUY4DpQ7NS61/B2bYfkkLzQA 3Ikm/oDmZ6+pdfOa0C3LCk0GBRFY+s0Wls7BrE0SAoARfYVRKePNfTkENlqww6oHDPl4 ODQNtRe06bUS0H9/mRj1InHXOumSUavBa61MQHkKQZB5wThbcVj9kBDvq9dBYO7am2pv c9Yw==
X-Received by 10.152.20.40 with SMTP id k8mr4163783lae.25.1372991278349; Thu, 04 Jul 2013 19:27:58 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <kr59i3$8jb$1@ger.gmane.org>
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.4211.1372924504.3114.python-list@python.org> <kr491h$g2t$1@dont-email.me> <51d62039$0$29999$c3e8da3$5496439d@news.astraweb.com> <kr59i3$8jb$1@ger.gmane.org>
From Joshua Landau <joshua.landau.ws@gmail.com>
Date Fri, 5 Jul 2013 03:27:18 +0100
Subject Re: Default scope of variables
To Dave Angel <davea@davea.name>
Content-Type text/plain; charset=UTF-8
Cc python-list <python-list@python.org>
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.4265.1372991287.3114.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372991287 news.xs4all.nl 15897 [2001:888:2000:d::a6]:37444
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49923

Show key headers only | View raw


On 5 July 2013 03:03, Dave Angel <davea@davea.name> wrote:
> On 07/04/2013 09:24 PM, Steven D'Aprano wrote:
>> On Thu, 04 Jul 2013 17:54:20 +0100, Rotwang wrote:
>>> It's perhaps worth mentioning that some non-ascii characters are allowed
>>> in identifiers in Python 3, though I don't know which ones.
>>
>> PEP 3131 describes the rules:
>>
>> http://www.python.org/dev/peps/pep-3131/
>
> The isidentifier() method will let you weed out the characters that cannot
> start an identifier.  But there are other groups of characters that can
> appear after the starting "letter".  So a more reasonable sample might be
> something like:
...
> In particular,
>     http://docs.python.org/3.3/reference/lexical_analysis.html#identifiers
>
> has a  definition for id_continue that includes several interesting
> categories.  I expected the non-ASCII digits, but there's other stuff there,
> like "nonspacing marks" that are surprising.
>
> I'm pretty much speculating here, so please correct me if I'm way off.

For my calculation above, I used this code I quickly mocked up:

> import unicodedata as unidata
> from sys import maxunicode
> from collections import defaultdict
> from itertools import chain
>
> def get():
>     xid_starts = set()
>     xid_continues = set()
>
>     id_start_categories = "Lu, Ll, Lt, Lm, Lo, Nl".split(", ")
>     id_continue_categories = "Mn, Mc, Nd, Pc".split(", ")
>
>     characters = (chr(n) for n in range(maxunicode + 1))
>
>     print("Making normalized characters")
>
>     normalized = (unidata.normalize("NFKC", character) for character in characters)
>     normalized = set(chain.from_iterable(normalized))
>
>     print("Assigning to categories")
>
>     for character in normalized:
>         category = unidata.category(character)
>
>         if category in id_start_categories:
>             xid_starts.add(character)
>         elif category in id_continue_categories:
>             xid_continues.add(character)
>
>     return xid_starts, xid_continues

Please note that "xid_continues" actually represents "xid_continue - xid_start".

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