Strange variable scope... is this right?
Patricia Hawkins
phawkins at spamnotconnact.com
Sat Jan 20 19:26:27 EST 2001
>>>>> "g" == gradha <gradha at iname.com> writes:
g> I expected python to bark at me like C would, but from what I read in the
g> tutorials, this seems to be one of those variable scope issues, right?
g> AFAICS, python will create a different variable scope at both for's,
g> hence the possibility to reuse the variable name f, since it means a
g> different thing at each scope, being unavailable from outside it's scope.
Ahem! Woof, woof:
[pjh at judith pjh]$ cat scope.c
#include <stdio.h>
main()
{
int a = 3;
printf ("outer a: %i \n", a);
{
int a = 77;
printf("inner a: %i \n", a);
}
printf ("bottom: outer a: %i \n", a);
}
[pjh at judith pjh]$ gcc scope.c
[pjh at judith pjh]$ ./a.out
outer a: 3
inner a: 77
bottom: outer a: 3
[pjh at judith pjh]$
Are-there-no-c-programmers-among-us-ly yours,
Patricia
--
Patricia J. Hawkins
Hawkins Internet Applications, LLC
More information about the Python-list
mailing list