4 ms·
> But I'm not sure, and in any event leaking loop vars was fixed at some point. (Good. It was useful but bug-prone. Just like this PEP!) So, basically, they ha
by UncleEntity 8y ago
> But I'm not sure, and in any event leaking loop vars was fixed at some point. (Good. It was useful but bug-prone. Just like this PEP!)
So, basically, they have a proposal for an expression that explicitly says "I want to leak this variable into the enclosing scope" and it is less useful than the implicit old way?
Python's variable scoping rules are a mess anyway -- some are function level, some are block level and I usually can't tell which is which until the compiler complains...
- camel_Snake 8y agoLocal -> Enclosing -> Global -> Builtin I use Python the most so maybe I'm just used to it but I always found scoping pretty straightforward. Do you have an example that you found surprising?
- UncleEntity 8y agoMostly I can't remember if a variable escapes from an if-else block, context manager, &etc until I start playing around with the code. In C it's 100% clear, variables only live inside their respective blocks so if you want to mess with the value in an if-else you have to declare it outside of the block.
- carapace 8y ago> So, basically, they have a proposal for an expression that explicitly says "I want to leak this variable into the enclosing scope" and it is less useful than the implicit old way? Goddamnit, I think you just changed my mind. :-)