In C, it's a common pattern to use temporary variables in an lexical
scope to prevent the global scope from getting dirty.
For example,

```C
int a[N];
for (int i = 0; i < N; i++) {
  int temp = ...
  a[i] = ... // something got from temp
}
// temp do not exists here
```

But in python, such a pattern seems impossible. An straightforward
translation should be like this:

```python
a = []
for i in range(N):
    temp = ...
    a.append(...)# something got from temp
# temp DO EXISTS here, will be the value of the last iteration
```

As in the comment, the temporary variable remains existing after the
block. How do you usually deal with this?
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to