|
|
|
|
|
by jmconfuzeus
1349 days ago
|
|
Dunno what you mean by getting it right tbh. for i in range(10) The statement literally declares or sets a variable named i in that scope. When the loop exits, i still exists in the scope with the value 9. If you call a function that was given a reference to i, the value will be 9 as expected because the function was called after the loop exited. Don't see any quirk or mistake here. |
|
For instance the behaviour of a Python loop varies drastically depending on the size of the iteration:
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.