Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28906
| References | <CAN1F8qXpeHAQGJG9urY2NjL_01gX++cMhkgiD3mt3nZsYzYcJQ@mail.gmail.com> |
|---|---|
| Date | 2012-09-12 08:22 +1000 |
| Subject | Re: Double sided double underscored variable names |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.521.1347402141.27098.python-list@python.org> (permalink) |
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 | Next — Next in thread | Find similar | Unroll 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