string.join() syntax quirky?
Matt Gerrans
mgerrans at ix.netcom.com
Fri Nov 30 16:28:37 EST 2001
> > I've decided to do what I should have from the beginning: always use
> > string.join. I didn't want to because it seemed silly to import a whole
> > module for one function, and as long as I'm using Official String Methods
> > for everything else I should use them for joins too.
>
> I think this is no big deal, since the string module maps most of its
> actions including join to the string methods.
> Of course, this will slightly reduce the performance, but the module itself
> is pretty light-weight.
>
> Moreover, I think readable code is more important than performance.
Additionally, if you really hate to import string, this is easy enough to add:
def join( seq, sep=' ' ):
return sep.join(seq)
- mfg
More information about the Python-list
mailing list