join vs instances

Robin Becker robin at
Sun Dec 9 22:56:26 CET 2001

In article <U7QQ7.45073$pP5.5620942 at>, Brad
Bollenbach <bbollenbach at> 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)?
well since UserStrings can be added to strings

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

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