Class Variable Access and Assignment

Paul Rubin http
Fri Nov 4 05:32:17 EST 2005


Mike Meyer <mwm at mired.org> writes:
> I've already argued that the kludges suggested to "solve" this problem
> create worse problems than this.

The most obvious solution is to permit (or even require) the
programmer to list the instance variables as part of the class
definition.  Anything not in the list is not an instance variable,
i.e. they don't get created dynamically.  That's what most other
languages I can think of do.  Some Python users incorrectly think this
is what __slots__ does, and try to use __slots__ that way.  That they
try to do that suggests that the approach makes some sense.



More information about the Python-list mailing list