sum and strings

Steve Holden steve at holdenweb.com
Fri Aug 18 12:26:52 EDT 2006


bearophileHUGS at lycos.com wrote:
> Paul Rubin:
> 
>>Sybren Stuvel:
>>
>>>Because of "there should only be one way to do it, and that way should
>>>be obvious". There are already the str.join and unicode.join methods,
>>
>>Those are obvious???
> 
> 
> They aren't fully obvious (because they are methods of the separator
> string), but after reading some documentation about string methods, and
> after some tests done on the Python shell, you too can probably use
> then without much problems.
> 
Using a bound method can make it a little more obvious.

  >>> cat = "".join
  >>> cat(['one', 'two', 'three'])
'onetwothree'
  >>> cat([u'one', u'two', u'three'])
u'onetwothree'
  >>>

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list