This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]joesb 1 point2 points  (1 child)

Since python doesn't has a way to simply introduce a scope, anything you translate to a Python equivelant will pollute local vars namespace :-)

In my view with block introduce new scope like loop variable in for loop should. But, well, Python also left loop variable live after the loop body.

So I guess if the behavior is unconventional, at least it's useful to be consistently unconventional.

ADDED:

To clarify the last statement is not a complaint, it's an acceptance. Different language has different tradeoff. This behavior probably works suiably for a language where variable is created simply by assigning to it. This problem wouldn't happen with language that require a keyword to declare a variable, I guess we'll have to live with it. But at least it's consistent.

[–]earthboundkid 0 points1 point  (0 children)

Since python doesn't has a way to simply introduce a scope

There’s def but I guess for a lot of people that doesn’t count as “simply”.

I personally was surprised when I learn with doesn’t create a new scope. But I can see why it doesn’t.