Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'that?': 0.05; 'subject:Python': 0.06; 'granted,': 0.07; '(currently': 0.09; 'created,': 0.09; 'namespace': 0.09; 'pep': 0.09; 'url:github': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"and"': 0.16; 'builtins': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'modules,': 0.16; 'parser.': 0.16; 'reliably': 0.16; 'statement.': 0.16; 'subject:library': 0.16; 'url:peps': 0.16; 'language': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'thu,': 0.19; 'later': 0.20; 'feb': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'instance,': 0.24; 'url:dev': 0.24; 'cc:2**0': 0.24; 'script': 0.25; '(for': 0.26; 'supported': 0.26; 'header:In-Reply-To:1': 0.27; 'draft': 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'included': 0.31; 'code': 0.31; 'usually': 0.31; 'keywords,': 0.31; 'restricted': 0.31; 'languages': 0.32; 'up.': 0.33; 'url:python': 0.33; 'actual': 0.34; 'subject:the': 0.34; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'curious': 0.36; 'instances': 0.36; 'maintained': 0.36; 'proposals': 0.36; 'url:org': 0.36; 'being': 0.38; 'others.': 0.38; 'pm,': 0.38; 'reported': 0.39; 'either': 0.39; 'even': 0.60; 'expression': 0.60; 'signal': 0.60; 'most': 0.60; 'full': 0.61; "you're": 0.61; 'here:': 0.62; 'name': 0.63; 'skip:n 10': 0.64; 'choose': 0.64; 'more': 0.64; 'worth': 0.66; 'latest': 0.67; '20,': 0.68; 'date,': 0.68; 'feeling': 0.68; "'from'": 0.84; "'when'": 0.84; 'everything,': 0.84; 'gut': 0.84; 'rexx,': 0.84; 'url:master': 0.84; 'proposal,': 0.91; 'to:none': 0.92 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:cc :content-type; bh=6KxDmPUfVPfAy2dO4A5Q9bz6fOdqNCv39xIFzOWpxOI=; b=KvbHMJZHUTPzHBS7tsGV1m4w4hTcg8hOEzaYxcd9GQfs6HN7qkqzBUrPMuigKawg7q ojC6IzFzGJFF60e0PylWuIfpBHvGs6eUeCNCtdAH4MaZzvafm+Zf8MwKRpKGtyJezu8C FJ26IjzHdS8ODGhDz7uTDMsecIp7f/ardgbWBZNfWlBqzpZ+/SZy6f/0UPFp7pxRvqBh OwafRbFCgc9vCybi/UoeI0bAWtzc27eVGO6mplu3t6kuXIk/pTaXeMBoAeIfp3QVdsNX g9QHRnqRc4SdwY77DU6CRkQD4+/3KfqqJ7TbbCj6sPNjUItFu5uOQPRa17zgLnNWDrsX TXyA== MIME-Version: 1.0 X-Received: by 10.68.98.3 with SMTP id ee3mr1158018pbb.31.1392893039402; Thu, 20 Feb 2014 02:43:59 -0800 (PST) In-Reply-To: <87mwhm6q3e.fsf@elektro.pacujo.net> References: <87mwhm6q3e.fsf@elektro.pacujo.net> Date: Thu, 20 Feb 2014 21:43:59 +1100 Subject: Re: Commonly-used names in the Python standard library From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392893048 news.xs4all.nl 2976 [2001:888:2000:d::a6]:57370 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66745 On Thu, Feb 20, 2014 at 9:22 PM, Marko Rauhamaa wrote: > from py35 import * > > That way, you could choose between: > > unless x > 7: > return > > and: > > py35.unless x > 7: > return > > in case you have already made use of the name "unless" in your program. What about return? Are you allowed to namespace that? And 'from' and 'import' and '*'? In languages with keywords, they're there to signal things to the parser. There are languages that have no keywords at all, like REXX, and their grammars are usually restricted to non-alphabetic tokens (for instance, REXX has & and | instead of "and" and "or"). Python already has most of its important names in either builtins (which can be shadowed) or actual modules, so it's only actual language keywords that can't be reused; and there aren't all that many of those. But more can be created, and it's worth being careful. In this instance, various proposals included "then", "when", "use", and "raises". My script reported the following: 1 instances of the name 'use' 12 instances of the name 'when' and none of either of the others. Granted, the stdlib isn't everything, and isn't even reliably representative, but that supported my gut feeling that keywording 'when' would be likely to trip code up. If you're curious about the full proposal, it's PEP 463, an expression form of the 'except' statement. The latest draft PEP can be found here: https://raw2.github.com/Rosuav/ExceptExpr/master/pep-0463.txt and the official repo (currently out of date, but later on will be the official and maintained version) has it here: http://www.python.org/dev/peps/pep-0463/ ChrisA