Issue28419
Created on 2016-10-11 21:38 by David Eyk, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| comp_scope.py | David Eyk, 2016-10-11 21:38 | |||
| Messages (3) | |||
|---|---|---|---|
| msg278505 - (view) | Author: David Eyk (David Eyk) | Date: 2016-10-11 21:38 | |
I've discovered what appears to be a scoping bug in Python 3.5.1, where the class scope is not available inside a list comprehension defined in the class scope. Attached is a simple example script, also available at the following gist: https://gist.github.com/eykd/c63a7cf760a538ee8bc3828362ed12e3 As demonstrated, the script runs fine in Python 2.7.11, but fails in 3.5.1. I can't think of any good reason why the class scope wouldn't be available to the comprehension scope, but if there is a reason, I'm keen to know what it is! |
|||
| msg278510 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2016-10-11 23:20 | |
See issue 11796, and the issue it is marked as a duplicate of, for an explanation. |
|||
| msg278512 - (view) | Author: David Eyk (David Eyk) | Date: 2016-10-12 00:01 | |
Thanks for the pointer. That seems weird and arbitrary when you think of it in terms of scope, but what can you do? All the same, thanks for the quick response. :) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:38 | admin | set | github: 72605 |
| 2016-10-12 00:01:04 | David Eyk | set | messages: + msg278512 |
| 2016-10-11 23:20:48 | r.david.murray | set | status: open -> closed superseder: Comprehensions in a class definition mostly cannot access class variable nosy:
+ r.david.murray |
| 2016-10-11 21:38:57 | David Eyk | create | |
