String.join revisited (URGENT for 1.6)
Johannes Stezenbach
yawyi at gmx.de
Tue May 30 07:24:42 EDT 2000
Fredrik Lundh <effbot at telia.com> wrote:
>Greg Ewing wrote:
>> So what? It's also been pointed out that it's quite feasible
>> to define a join that makes sense for more than just strings,
>> and that string joining can be efficiently accommodated as a
>> special case.
>
>that's really a different topic.
You tell us to reason because voting doesn't help.
We reason and you tell us we're reasoning about the wrong topic.
Interesting...
Let me summarize:
- I want to convince you to change sep.join(list) to list.join(sep)
for aesthetical reasons.
- Arguments regarding this aesthetical reasons directly ("looks better",
"easier for beginners", "less error prone") apparently don't count.
- Argumenting implementation-wise ("generalize the meaning of join
so string-join becomes a special-case optimization and list.join(sep)
becomes the logical thing to do") is turned down because generalized
join could be misused on non-concatenable objects.
(With regard to a generalized join() definition, overloading '+'
to mean "add" and "concatenate" is a Python design flaw.)
>(and be careful with overgeneralizations: neither "joining
>numbers" nor "reducing strings" make much sense...).
In Perl joining numbers means converting them to strings and then
join the numeric strings. This /could/ be done in python as well...
(Notice that I didn't say "should", but if you stand to your opinion
that join does only make sense for strings, then automatically
converting stuff to strings would also make sense.)
>if you think that keeping string.join in there is the most serious
>design mistake in 1.6, you may be in for some really interesting
>surprises...
I've asked this one before:
Is " ".join() only an implementation detail needed to write
string.join() that nobody should ever call directly?
If so, then *say it loud and clear*. And rename " ".join to
" ".__join__ or " ".__never_call_this_join_directly__.
I was happy with string.join() before and I will be happy
with string.join() in the furure. I just don't want to have
to read code that uses " ".join(list), and I don't want to read
endless repetitions of newbie's postings in c.l.p asking
"why does join() work the wrong way round?"
Johannes
More information about the Python-list
mailing list