Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101382
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Unable to access module attribute with underscores in class method, Python 3 |
| Date | 2016-01-09 03:16 +1100 |
| Message-ID | <mailman.74.1452269803.2305.python-list@python.org> (permalink) |
| References | <mailman.62.1452258624.2305.python-list@python.org> <568fded7$0$1608$c3e8da3$5496439d@news.astraweb.com> |
On Sat, Jan 9, 2016 at 3:07 AM, Steven D'Aprano <steve@pearwood.info> wrote:
> If you absolutely insist that you must must must continue to use a double
> underscore name, you could also try this:
>
> py> __a = 1
> py> class Test:
> ... def method(self):
> ... x = eval("__a")
> ... print(x)
> ...
> py> Test().method()
> 1
>
>
> But don't do that.
Seriously? You consider that less bad than globals()["__a"]?
But all of this is craziness to support craziness. It's not asking
which inmate should run the asylum - it's asking which of my multiple
personalities should be elected fourteen-year-old queen.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unable to access module attribute with underscores in class method, Python 3 Joseph Fox-Rabinovitz <jfoxrabinovitz@gmail.com> - 2016-01-07 11:14 -0500
Re: Unable to access module attribute with underscores in class method, Python 3 Steven D'Aprano <steve@pearwood.info> - 2016-01-09 03:07 +1100
Re: Unable to access module attribute with underscores in class method, Python 3 Chris Angelico <rosuav@gmail.com> - 2016-01-09 03:16 +1100
Re: Unable to access module attribute with underscores in class method, Python 3 Steven D'Aprano <steve@pearwood.info> - 2016-01-09 12:25 +1100
csiph-web