[Python-ideas] Fixing class scope brainstorm

Eric Fahlgren ericfahlgren at gmail.com
Tue Mar 27 13:28:59 EDT 2018


On Tue, Mar 27, 2018 at 9:52 AM, Paul Moore <p.f.moore at gmail.com> wrote:

> I'd actually like to see some real world use cases to get a feel for
> whether this is even worth worrying about. (I'm not saying it isn't,
> just that it's hard to get a feel for the importance based on
> artificial examples).
>

​The only reason I brought it up was because I ran into this about three
weeks ago porting some old Python 2 to 3, where there was a class level
comprehension that referenced a class variable on the lhs.  I simply
removed it by enumerating the cases by hand, no big deal, but it did take
me a while to figure out why ​that no longer worked.

My specific case looked approximately like this:

class Plugin:
    plugin_dir = 'somepath'
    plugin_names = [os.join(plugin_dir, name) for name in ('list', 'of',
'names')]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180327/cf01366c/attachment.html>


More information about the Python-ideas mailing list