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

D-Man dsh8290 at rit.edu
Wed Mar 7 15:31:42 EST 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.  You almost expect some weird function to jump out of this
| syntax.  It looks very Ruby/Perl-esque.
| 

Even with my newfound understanding, provided by the Martellibot, I
agree with this.  Calling a method on an object is fine.  Calling it
on a literal looks weird.  Take for example something like this

three = 1.__add__( 2 )

;-)


Anyways, after seeing part of the discussion here I tried a string
method on a string literal in Java and it worked as well.

I still sort of disagree with string methods like 'replace'.  After
all, it doesn't really replace anything.  It creates a new object with
the proper differences.  Perhaps if 'replace!' were also added to
it might be clearer.

-D





More information about the Python-list mailing list