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/070245.html below:

[Python-Dev] __str__ and unicode

[Python-Dev] __str__ and unicode [Python-Dev] __str__ and unicodeMichael Urman murman at gmail.com
Wed Dec 6 15:15:29 CET 2006
> I don't have anything older than 2.4 laying around either, but IIRC
> in 2.3 unicode() did not call __unicode__().

It turns out __unicode__() is called on Python 2.3.5.

% python2.3
Python 2.3.5 (#2, Oct 18 2006, 23:04:45)
[GCC 4.1.2 20061015 (prerelease) (Debian 4.1.1-16.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(object):
...   def __unicode__(self):
...     print "unicode"
...     return u"hi"
...   def __str__(self):
...     print "str"
...     return "hello"
...
>>> unicode(Foo())
unicode
u'hi'

-- 
Michael Urman  http://www.tortall.net/mu/blog
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