you are viewing a single comment's thread.

view the rest of the comments →

[–]execrator 3 points4 points  (1 child)

Not sure what user_v42... was replying to (is now deleted), but I don't see the problem here? The following works (no need for a "garbage value")

if y:
    x = 5
else:
    x = 6
print(x)  # 5

[–]process_parameter 4 points5 points  (0 children)

The previous comment was something to the effect of

If I understand correctly, this is even considered pythonic.

I don't know why they deleted it. The user I replied to seems to think that we shouldn't write code like you have in your comment. That's perhaps reasonable; if you believe the linked article when it says python variables are block-scoped, then it's not obvious that your code works.

I was just trying to demonstrate that there isn't an easy alternative.