Message369638
I don't think the examples you mention is proof of inconsistent behaviour:
> * list expressions do have their scope and do not overwrite local variables
comprehensions have their own scope in Python 3 and this is documented. General blocks (like normal loops, exceptions, with statements...etc don't have their own scope).
* with statement does overwrite the variable value but makes it available even after with block
Yeah, but with statements do not have the problem of needing to break reference cycles in the exception names, so this does not apply. The same for any other "target" variable such as loop assignment (for x in ...).
* except overwrites variable value, but then the value gets cleaned and no longer accessible.
This is a consequence of the fact that when you do 'as varname' you are voluntary overwriting the previous value, therefore loosing whatever was there before. The semantics here are that the variable is not accessible outside the except block, which is unique to except blocks but this is needed to avoid circular references. |
|
Date |
User |
Action |
Args |
2020-05-22 20:17:04 | pablogsal | set | recipients:
+ pablogsal, christian.heimes, Mark.Shannon, oleksandr.suvorov |
2020-05-22 20:17:03 | pablogsal | set | messageid: <1590178623.97.0.109389852169.issue40728@roundup.psfhosted.org> |
2020-05-22 20:17:03 | pablogsal | link | issue40728 messages |
2020-05-22 20:17:03 | pablogsal | create | |
|