[Python-Dev] Need a way to test for 8-bit-or-unicode-string
Tim 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>.