[Python-3000] Python 3000 Status Update (Long!)
Steve Howell
showell30 at yahoo.com
Thu Jun 21 19:33:41 CEST 2007
--- Andrew McNabb <amcnabb at mcnabbs.org> wrote:
>
> I think you're technically right, but I frequently
> find myself using the
> phrase "add together a list of strings" when it
> would be more accurate
> to say "concatenate a list of strings." I can't say
> I feel bad when I
> use this terminology.
>
Nope, and I wouldn't throw the grammar book at you if
you did. But if you said a compound word is a "sum"
of smaller words, I might look at you a little funny.
:)
>
> I guess I don't find the distinction between adding
> and concatenating as
> strong as you do.
>
Fair enough.
> When we write 'a' + 'b', I don't see any problem
> with saying that we're
> adding 'a' and 'b', and I don't think there's
> anything unclear about
> sum(['a', 'b', 'c']).
I think you're right that most people would guess that
the above returns 'abc', so we're not in major
disagreement.
But I'm approaching usability from another direction,
I guess. If I wanted to join a series of strings
together, sum() wouldn't be the most naturally
occuring method to me. To me it would be concat() or
join(). I think ''.join(...) in Python is a tiny
wart, since it's pretty unlikely for a newcomer to
guess the syntax, but I'm not sure they'd guess sum()
either. The one advantage of ''.join() is that you
can at least deduce it, via introspection, by doing
dir('foo').
My other concern with sum() is just the common pitfall
that you do sum(line_of_numbers.split(',')) and get
'35' when you intended to write code to get 8. I'd
rather have that fail obviously than subtlely.
____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
More information about the Python-3000
mailing list