[Python-ideas] local is safer than global
Cesare Di Mauro
cesare.di.mauro at gmail.com
Sun Jun 13 15:39:55 CEST 2010
2010/6/13 Antoine Pitrou <solipsis at pitrou.net>
> On Fri, 11 Jun 2010 21:18:48 -0400
> Demur Rumed <junkmute at hotmail.com> wrote:
> > For example,
> > def f(x):
> > a.append(x)
> > if len(a)>5:a=
> > If a is bound as a local, this throws an UnboundLocalError. Why then is
> it not set to try the global namespace, that place we cannot be so certain
> of the exception in?
> > It comes down to the view of UnboundLocalError as a feature or a bug
> Certainly a feature. In case of ambiguity, a variable should be
> considered local rather than global. It makes the language much safer.
> It's also why I'm -1 on your proposal.
> Python-ideas mailing list
> Python-ideas at python.org
Locals are also MUCH faster...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas