string.join() syntax quirky?

Chris Barker chrishbarker at home.net
Mon Nov 26 22:07:57 CET 2001


> > One way to look at it is that the various collection classes do NOT
> > inherit from a single base class (which would be a logical place to
> > define a join method). Hence to have all kinds of collections
> > learn to
> > "join" requires a lot of repeat coding. Making join a string method
> > solves this problem.
> 
> So instead of doing what's right we're doing what's convenient? Doesn't
> sound very Pythonic <wink>

Another way to look at is is that joining and splitting are inherently
string functionailty, and thus belong with the string object. Or the
string module, if you take the procedural view of programming. I don't
think join() belongs with sequences at all, as sequences can hold
anything,not just strings.

"".join(list) is a little clunky, but it makes sense to me.

-Chris





-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list