[Python-Dev] unicode and str (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Mon Aug 30 23:35:17 CEST 2004
- Previous message: [Python-Dev] unicode and __str__
- Next message: [Python-Dev] unicode and __str__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Neil Schemenauer wrote:
But unicode() will also return str, eg.
>>> class A: ... def str(self): ... return u'\u1234' ... >>> unicode(A()) u'\u1234' Why would I want to use unicode?
This class is incorrect: it does not support str().
Shouldn't we be heading to a world where str always returns unicode objects?
No. In some cases, str() needs to compromise, where unicode() doesn't.
Now, say your class stores unicode character data. You could have unicode return a unicode object and have str encode it somehow and return a str. However, that seems like a horrible design to me.
Perhaps. What are you proposing to do about this? Ban, from the face of the earth, what seems like a horrible design to you?
Regards, Martin
- Previous message: [Python-Dev] unicode and __str__
- Next message: [Python-Dev] unicode and __str__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]