Re: Feature Proposal: Sequence .join method
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Feature Proposal: Sequence .join method

From: David Murmann <david.murmann@rwth-aachen.de>
Date: Fri Sep 30 2005 - 05:33:34 CEST

> def join(sep, seq):
> return reduce(lambda x, y: x + sep + y, seq, type(sep)())

damn, i wanted too much. Proper implementation:

def join(sep, seq):
     if len(seq):
         return reduce(lambda x, y: x + sep + y, seq)
     return type(sep)()

but still short enough

see you,
David.
Received on Sat Oct 15 03:58:29 2005