|
|
|
|
|
by masklinn
1343 days ago
|
|
An equivalent construct works differently (and one would say in a way that is less error-prone) in other languages. For instance the behaviour of a Python loop varies drastically depending on the size of the iteration: def loop(n):
for i in range(n):
pass
print(i)
loop(10) # 9
loop(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in loop
UnboundLocalError: local variable 'i' referenced before assignment
That Python works this way is specific to Python. And a language which doesn't have the issues this implies would be "getting it right", in the sense of avoiding sharp corners and edge cases. |
|