Message21861
Logged In: YES
user_id=593130
This behavior does not, to me, clearly violate the current doc:
"Return a string which is the concatenation of the strings in
the sequence seq"
where string is bytestring or Unicodestring. If one takes
'string' narrowly, then your subclass instances should be
rejected as input. If one takes 'string' more broadly as
isinstance(s,basestring) then your subclass should be equally
acceptible as input or output. If neither consistent
interpretation of 'string' is meant, then there is a doc bug, or
at least an underspecification.
Workaround 0: if len(seq) == 1: ...
Workaround 1. map(str, seq)) to force str out.
*However*, in playing around (in 2.2), I discovered:
>>> type(''.join((a)))
<type 'str'>
>>> type(''.join([a]))
<class '__main__.ms'>
>>> type(''.join({a:None}))
<class '__main__.ms'>
Having the type of the join of a singleton depend on the type
(mutability?) of the singleton wrapper is definitely disquieting.
Workaround 2: tuple(seq)
|
|
Date |
User |
Action |
Args |
2007-08-23 14:24:40 | admin | link | issue1001011 messages |
2007-08-23 14:24:40 | admin | create | |
|