I come to praise .join, not to bury it...

Paul Jackson pj at sgi.com
Thu Mar 8 00:09:05 CET 2001


On Tue, Mar 06, 2001 at 09:46:53AM -0500, Mike C. Fletcher wrote:
| Here's a professional aesthetic's take:
| 
|       mystring.join( )
| 
| This is a perfectly normal and good-looking construct.  It seems pythonic
| and beautiful, object orientation is part of Python, and this works nicely.
| 
|       "'".join( )
|       ";".join( )
|       ".".join( )
|       "!".join( )
|       ",".join( )
| 
| All look like executable line noise.  That is, the literal string's syntax
| makes the use of dotted attributes on such a string look jarring and
| off-putting.


Hmmmm ... the following looks nicer to the part of my
brain that agreed with the above sighting of noise:

    str(",").join(x)

as in:

    >>> x=['a', 'b', 'c']
    >>> str(",").join(x)
    'a,b,c'

But my hunch is that the above will quickly look like a silly
example of excess elaboration to a frequent reader of Python code.

Time to get used to simply:

    ",".join(x)

-- 
                          I won't rest till it's the best ...
                          Manager, Linux System Software
                          Paul Jackson <pj at sgi.com> 1.650.933.1373



More information about the Python-list mailing list