[Baypiggies] deleting an inherited attribute?
Rob Miller
ra at burningman.com
Tue Aug 8 23:47:46 CEST 2006
hi,
i have a situation where one of my classes is inheriting an attribute defined
at the class level of one of my base classes, like so:
class SuperClass:
value = 'Foo'
class MyClass(SuperClass):
pass
the problem is that i don't need the 'value' attribute at all, and in fact its
very existence is causing problems with some other dependency code. there is
a call elsewhere that is doing something like this:
myinstance = MyClass()
if hasattr(myinstance, 'value'):
print "this is the wrong result"
else:
print "this is what i want to happen"
is there some way to remove the inherited attribute from MyClass's namespace?
i've tried putting 'del MyClass.value' or 'del self.value' in MyClass's
__init__ method, but i get AttributeErrors. 'del SuperClass.value' works, of
course, but that would then impact SuperClass itself, and all of the other
consumers of SuperClass, which won't do.
any suggestions?
-r
More information about the Baypiggies
mailing list