Chris Angelico wrote:
Classes and functions behave differently. Inside a function, a name is
local if it's ever assigned to; but in a class, this is not the case.

Actually, it is. Assigning to a name in a class body makes it part
of the class namespace, which is the local namespace at the time
the class body is executed.

The unusual thing about a class namespace is that it doesn't
form part of the scope of closures created within the class.
So methods, for example, can't directy see attributes of the
class they're defined in.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to