On 30 dic, 17:25, Torsten Bronger <[EMAIL PROTECTED]>
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.
Are you sure you *really* want to inherit from unicode? Don't you want
to store an unicode object as an instance attribute?

> Unfortunately, unicode objects don't have a __unicode__ method.

Because it's not needed; unicode objects are already unicode objects,
and since they're immutable, there is no need to duplicate them. If it
existed, would always return self.

> However, unicode(super(Excerpt, self)) is also forbidden because
> super() allows attribute access only (why by the way?).

(because its purpose is to allow cooperative methods in a multiple
inheritance hierarchy)

> How does my object get its own value?

"its own value" is the instance itself

--
Gabriel Genellina
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to