Sub-classing unicode: getting the unicode value

John Machin sjmachin at lexicon.net
Sun Dec 30 17:32:30 EST 2007


On Dec 31, 8:08 am, Torsten Bronger <bron... at physik.rwth-aachen.de>
wrote:
> Hallöchen!
>
> Gabriel Genellina writes:
> > On 30 dic, 17:25, Torsten Bronger <bron... at physik.rwth-aachen.de>
> > wrote:
>
> >> I sub-classed unicode in an own class called "Excerpt", and now I
> >> try to implement a __unicode__ method.  In this method, I want to
> >> get the actual value of the instance, i.e. the unicode string:
>
> > The "actual value of the instance", given that it inherits from
> > unicode, is... self.
>
> But then it is not unicode but Excerpt which I don't want.  The idea
> is to buffer the unicode representation in order to gain efficiency.
> Otherwise, a lot of unicode conversion would take place.
>

I'm confused: you are subclassing unicode, and want to use several
unicode methods, but the object's value appears to be an 8-bit
string!?!?

Care to divulge the code for your __init__ method?



More information about the Python-list mailing list