Re: [Tutor] how to make an lexical scope block?

2017-08-05 Thread Alan Gauld via Tutor
CCing the list. Always use ReplyAll or ReplyList when responding to the list. On 05/08/17 18:17, Xiaosong Chen wrote: > 2) Also we avoid importing with the >> from foo import * >> >> even if you import with >> >> import foo >> >> foo.temp can still be accessed. When you use autocomplete in an >> i

Re: [Tutor] how to make an lexical scope block?

2017-08-05 Thread Alan Gauld via Tutor
On 05/08/17 08:23, Xiaosong Chen wrote: > In C, it's a common pattern to use temporary variables in an lexical > scope to prevent the global scope from getting dirty. This was very common in the early days of C - around 1979-1985 - when compilers often only considered the first 4 (or 6) characters

Re: [Tutor] how to make an lexical scope block?

2017-08-05 Thread Steven D'Aprano
On Sat, Aug 05, 2017 at 03:23:57PM +0800, Xiaosong Chen wrote: > In C, it's a common pattern to use temporary variables in an lexical > scope to prevent the global scope from getting dirty. [...] > But in python, such a pattern seems impossible. An straightforward > translation should be like this:

Re: [Tutor] how to make an lexical scope block?

2017-08-05 Thread Peter Otten
Xiaosong Chen wrote: > 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

[Tutor] how to make an lexical scope block?

2017-08-05 Thread Xiaosong Chen
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 patt