Why less emphasis on private data?

Gabriel Genellina gagsl-py at yahoo.com.ar
Sun Jan 7 15:35:42 EST 2007


On 7 ene, 16:13, John Nagle <n... at animats.com> wrote:

>      Because Python doesn't have explicit declarations, scope of variables is
> a touchy issue.  If you write "x = 1" within a function, that will
> create a local "x" if "x" doesn't exist, or alter a global "x" if "x" was
> previously created in the global context.  But at least global variables
> are local to the namespace; we don't have clashes across files.  
No, `x=1` always uses a local variable x, unless an (explicit!) global
statement was in effect in the same block. This, and the explicit self,
make very clear which x you are referring to.

-- 
Gabriel Genellina




More information about the Python-list mailing list