In message <4cb14f8c$0$1627$742ec...@news.sonic.net>, John Nagle wrote:

> Within "fn1", the first reference to "self.classvar" references the class-
> level version of "classvar".  The assignment overrides that and creates an
> object-level instance of "self.classvar". Further references to
> self.classvar" in f1 then reference the object-level "classvar"

I’d say there is definitely an inconsistency with the absoutely anal 
restrictions on global variables, i.e. the well-known sequence

    ... reference to globalvar ...
    globalvar = newvalue

which triggers the error “UnboundLocalError: local variable 'globalvar' 
referenced before assignment”.

It seems to me the same principle, that of disallowing implicit overriding 
of a name from an outer scope with that from an inner one after the former 
has already been referenced, should be applied here as well.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to