A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-December/070237.html below:

[Python-Dev] __str__ and unicode

[Python-Dev] __str__ and unicode [Python-Dev] __str__ and unicodeFredrik Lundh fredrik at pythonware.com
Wed Dec 6 10:26:32 CET 2006
over at my work copy of the python language reference, Adrian Holovaty
asked about the exact semantics of the __str__ hook:

    http://effbot.org/pyref/__str__

   "The return value must be a string object." Does this mean it can be a
   *Unicode* string object? This distinction is ambiguous to me because
    unicode objects and string objects are both subclasses of basestring.
    May a __str__() return a Unicode object?

I seem to remember earlier discussions on this topic, but don't recall when
and what.  From what I can tell, __str__ may return a Unicode object, but
only if can be converted to an 8-bit string using the default encoding.  Is this
on purpose or by accident?  Do we have a plan for improving the situation
in future 2.X releases ?

</F> 



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4