join vs instances

Robin Becker robin at jessikat.fsnet.co.uk
Sun Dec 9 22:56:26 CET 2001


In article <U7QQ7.45073$pP5.5620942 at news1.rdc1.mb.home.com>, Brad
Bollenbach <bbollenbach at home.com> writes
.....
>Of course it's expected that you can't get away with simply referring to
>the instance directly and expecting a string to pop out, but can you 
>give an example of a gotcha with a UserString vs. builtin (that is to say, 
>a scenario where you the difference between the two will make it 
>impossible for you to write code that won't break)?
>
>
>Brad
well since UserStrings can be added to strings

eg
>>> from UserString import UserString
>>> u = UserString('U')
>>> u+'a'
'Ua'
>>> 'a'+u
'aU'
>>>

I had expected that the join operation would also apply to UserStrings
somehow or that there would be some magic method that would allow join
to be applied to user strings, but I can't find out how. What is the
primitive implementation of join?
-- 
Robin Becker



More information about the Python-list mailing list