how do i create such a thing?
Lowell Kirsh
lkirsh at cs.ubc.ca
Sun Jan 30 16:54:38 EST 2005
I want to create a class called DefaultAttr which returns a default
value for all attributes which haven't been given values yet. It will
work like this:
>> x = DefaultAttr(99)
>> print x.foo
99
>> print x.bar
99
>> x.foo = 7
>> print x.foo
7
I already have a similar class called DefaultDict which works similarly
which I assume would be a good thing to use.
Lowell
More information about the Python-list
mailing list