|
|
|
|
|
by dragonwriter
1346 days ago
|
|
> Unfortunately, Python is simply inconsistent in this regard. For example, list comprehensions leak the variable for back-compat reasons No, they don’t. They did in Python 2—list comps were introduced in 2.0, genexps in 2.4, and set/dict comps in 3.0 but also included in the later 2.7 release—but that’s been non-current for more than a decade, and conpletely out of support for two years. Let it go. > But, backwards compatibility aside, the language could change to make for-loops behave like sequence comprehensions wrt scoping. Sure in Python 4, but after 2->3, not sure many people are looking forward to that. |
|