[Tutor] scope/namespaces

Kent Johnson kent37 at tds.net
Tue Apr 24 12:34:42 CEST 2007


ammar azif wrote:
> Something in python disturbs me ,
> 
> when i write a for loop,
> 
> i am able to access the variable declared in that loop after the loop 
> finishes which i am not able to do in languages like c/c++ or java. Is 
> it different in python?

Yes, it is different. In Python a block is not a scope. Names bound 
within the block, including the loop variable, are accessible outside 
the block.

Kent


More information about the Tutor mailing list