[Tutor] inheriting different builtin types

Willi Richert w.richert at gmx.net
Thu Feb 5 09:24:50 CET 2009


Hi,

http://objectmix.com/python/710201-dynamically-changing-base-class.html may be 
of interest.

wr

On Mittwoch, 4. Februar 2009 14:27:17 spir wrote:
> 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
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090205/34174ceb/attachment.htm>


More information about the Tutor mailing list