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/2001-October/017836.html below:

[Python-Dev] Need a way to test for 8-bit-or-unicode-string

[Python-Dev] Need a way to test for 8-bit-or-unicode-stringTim Peters tim.one@home.com
Mon, 8 Oct 2001 03:54:59 -0400
[Guido]
> ...
> [*] For a while I toyed with the idea of calling the abstract base
> class 'string', and hacking import so that sys.modules['string'] is
> the string class.  The abstract base class should then have methods
> that invoke the concrete implementations, so that string.split(s)
> would be the same as s.split().
> ...
> Unfortunately this broke down when I realized that the signature of
> string.join() is wrong for the string module: the string.join function
> is string.join(sequence, stringobject) while the signature of the
> string method is join(stringobject, sequence).
> ...
> (Hm, it could be saved by making string.join() accept the arguments
> in either order.  Gross. :-)

Luckily, it's also hopeless:

>>> string.join('abc', ' - ')
'a - b - c'
>>>

That is, since strings are also sequences, there's no way to disambiguate
the pass-2-strings case.  Although, if you ask me, it's obvious I wanted the
result shown instead of ' abc-abc ' <wink>.




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