[Tutor] inheriting different builtin types

spir denis.spir at free.fr
Wed Feb 4 14:27:17 CET 2009


Hello,

I have a strange problem and cannot see a clear method to solve it.
I would like to build a custom type that is able to add some informational attributes and a bunch attribute to a main "value". The outline is then:

class Custom(X):
	def __init__(self, value, more):
		X.__init__(self)
		<define info attributes>
	<custom methods>

The base class is here to inherit value's behaviour and to avoid writing obj.value all the time. For this type will be heavily used by client code.
The point is, this value may actually be of several builtin types. Logically, X is value.__class__. I imagine there are solutions using a factory, or __new__, or maybe metaclass (never done yet)? I cannot find a working method myself.

Denis

------
la vida e estranya


More information about the Tutor mailing list