[Python-Dev] RE: [Python-Dev] Re: [Python-Dev] String methods... finally

Mark Hammond MHammond at skippinet.com.au
Tue Jun 15 10:28:55 CEST 1999


> hmm.  consider the following:
>
>     space = " "
>     foo = L"foo"
>     bar = L"bar"
>     result = space.join((foo, bar))
>
> what should happen if you run this:
>
>     a) Python raises an exception
>     b) result is an ordinary string object
>     c) result is a unicode string object

Well, we could take this to the extreme, and allow _every_ object to grow a
join method, where join attempts to cooerce to the same type.

Thus:
" ".join([L"foo", L"bar"]) -> "foo bar"
L" ".join(["foo", "bar"]) -> L"foo bar"
" ".join([1,2]) -> "1 2"
0.join(['1',2']) -> 102
[].join([...]) # exercise for the reader ;-)

etc.

Mark.





More information about the Python-Dev mailing list