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/2002-June/025855.html below:

why string substitution is not the same operation as data formatting

[Python-Dev] PEP 292-related: why string substitution is not the same operation as data formatting [Python-Dev] PEP 292-related: why string substitution is not the same operation as data formattingSkip Montanaro skip@pobox.com
Sun, 23 Jun 2002 14:28:20 -0500
    Lalo> These strings may be the result of running some non-string objects
    Lalo> trough str(foo) - but, we are making no assumptions about these
    Lalo> objects. Just that str(foo) is somehow meaningful. And, to my
    Lalo> knowledge, there are no python objects for which str(foo) doesn't
    Lalo> work.

Unicode objects can't always be passed to str():

    >>> str(u"abc")
    'abc'
    >>> p = u'Scr\xfcj MacDuhk'
    >>> str(p)
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    UnicodeError: ASCII encoding error: ordinal not in range(128)

(My default encoding is "ascii".)

You need to encode Unicode objects using the appropriate charset, which may
not always be the default.

Skip




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