Typed Python?

Jacek Generowicz jacek.generowicz at cern.ch
Wed Jul 7 11:18:37 EDT 2004


David Bolen <db3l at fitlinxx.com> writes:

> Jacek Generowicz <jacek.generowicz at cern.ch> writes:
> 
> > The ambiguity in Python is abouth whether 'x=10' creates a new
> > binding, or rebinds an existing name. Before lexical scopes this was
> > disambiguated with the 'global' keyword. Now, that's not enough any
> > more.
> 
> Isn't it?  Binding is still always local unless you use the global
> keyword, it's just lookups that walk the scope hierarchy after lexical
> scoping was added to Python.  In fact, there's currently no way (that
> I can think of - well, maybe with mucking with frames manually) to
> rebind a name in an intermediate scope.  That could in fact be
> considered a wart in the nested scope support (PEP 227 indicates Guido
> was opposed to it), but it does maintain the unambiguous nature of
> name binding.

Heh. It's unambiguous in Python, because Python, when faced with an
ambiguous situation (x=10), always makes the same choice (create a
local x unless x was declared global). The consequence is that there
is no way for the programmer to express the fact that he prefers the
other choice (rebind the lexically innermost x).

So, if it's not an ambiguity then it's a lack of expressivity.



More information about the Python-list mailing list