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


Groups > comp.lang.python > #28906

Re: Double sided double underscored variable names

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'say,': 0.05; 'rename': 0.07; 'python': 0.09; 'notation': 0.09; 'sep': 0.09; 'underscore': 0.09; 'will,': 0.09; 'assume': 0.11; 'modification': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; "someone's": 0.16; 'subject:variable': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'specify': 0.17; 'variables': 0.17; 'variable': 0.20; 'names.': 0.22; "user's": 0.22; 'skip:_ 20': 0.22; "i'd": 0.22; "python's": 0.23; 'header:In-Reply-To:1': 0.25; '(which': 0.26; 'am,': 0.27; 'compiled': 0.27; 'message-id:@mail.gmail.com': 0.27; 'necessary,': 0.29; 'unlikely': 0.29; 'skip:_ 10': 0.29; 'code': 0.31; 'docs': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; '12,': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'to,': 0.65; 'special': 0.73; 'yourself': 0.77; 'adorn': 0.84; 'collision': 0.84; 'incredibly': 0.96
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=3IUzRpsaWC9eVwHL3ssWV7RMdglRIg2AkNWXqOxLREg=; b=JjGW/tg19AroljDS6pzBeuSw8+w2pH9kzsSUF7ldRmNzQOsuf5bAKSW9sxmE3FUase KIswtW21INtgwYK4aCi3/6IlV3Dmz7tnywE5hFALdiOgjCo487u3oDr0lqixtLKBH9ub 7Y3m7Et2MoJOXqaCx9/++QsuG4Si6RaRhymmd6oU9hsQlmjjyR4OcHtyAoDyjUKwJ6yo nNOJidsNp1eoFpVMNF65QN62FtQwxh7U+ovCCWA7PMEg3jwDlxfNweoEf8xmHdk3VsMq U1jNBvPSPifRdavvzclskrpCOXqRpRjeGNj1B2gMMqOG5CXYUcL+2E4QgyFDgaGDv64Q 9/OA==
MIME-Version 1.0
In-Reply-To <CAN1F8qXpeHAQGJG9urY2NjL_01gX++cMhkgiD3mt3nZsYzYcJQ@mail.gmail.com>
References <CAN1F8qXpeHAQGJG9urY2NjL_01gX++cMhkgiD3mt3nZsYzYcJQ@mail.gmail.com>
Date Wed, 12 Sep 2012 08:22:17 +1000
Subject Re: Double sided double underscored variable names
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.521.1347402141.27098.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1347402141 news.xs4all.nl 6899 [2001:888:2000:d::a6]:57600
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28906

Show key headers only | View raw


On Wed, Sep 12, 2012 at 8:09 AM, Joshua Landau
<joshua.landau.ws@gmail.com> wrote:
> If I were to use internal double-underscored names of the form
> __BS_internalname__, would the compiled code be able to assume that no-one
> had overwritten these variables and never will, even through modification
> of, say, locals(). I ask because Python's docs seem to specify that double
> sided double underscored names are strictly for Python and its special
> names.

Interesting. If you're compiling your code to Python, you may be able
to, if necessary, adorn a user's variable name(s). I'd be inclined to
use a single underscore notation like _BS_internalname_ and then, in
the event of a collision (which would be incredibly unlikely unless
someone's fiddling), rename the offending variable to
_BS_BS_something_ - which of course you'd never yourself use. Would
that serve?

ChrisA

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


Thread

Re: Double sided double underscored variable names Chris Angelico <rosuav@gmail.com> - 2012-09-12 08:22 +1000
  Re: Double sided double underscored variable names Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-12 00:51 +0000

csiph-web