Postpone creation of attributes until needed

Peter Otten __peter__ at web.de
Mon Jun 11 07:44:10 EDT 2007


Frank Millman wrote:

> I tried that, but I get AttributeError: 'A' object has no attribute
> '__dict__'.

That's what you get for (ab)using __slots__ without understanding the
implications ;)

You can instead invoke the __getattr__() method of the superclass:

super(A, self).__getattr__(name)

Peter



More information about the Python-list mailing list