Why doesn't python's list append() method return the list itself?

Nathan Rice nathan.alexander.rice at gmail.com
Wed Jul 14 09:21:17 EDT 2010


The better question is, do I ever use them? Thinking back over the code I've
written in the last couple of years, I would say probably two or three times
(mostly in unit tests).  I've had to code around string's sequence behavior
DOZENS of times.  Is it nifty that strings can be sliced like that?  Sure.
 In general my experience has been that the string methods (and some misc
functions in other modules) do a better job in simple cases, and regular
expressions do a better job in complex cases.  I just don't see string
slicing having utility that is irreplaceable, and it is bug-inducing in many
cases, or at the very least it can propagate programming errors way down
stream.

 Ultimately, I highly doubt it's going anywhere, so it's a moot point.  I
definitely feel that python is trading real usability for "flash" with
string slicing though.

On Tue, Jul 13, 2010 at 8:48 PM, Aahz <aahz at pythoncraft.com> wrote:

> [Original not available on my swerver, responding here]
>
> >On 7/11/10 10:03 PM, Nathan Rice wrote:
> >>
> >> Yeah, I long ago filed the in place place in the same folder as
> >> strings-as-sequences, all() returning True for an empty iterable and any
> >> returning True rather than the thing which triggered it.
>
> Because I love to repeat myself:
>
> "...string iteration isn't about treating strings as sequences of strings,
> it's about treating strings as sequences of characters.  The fact that
> characters are also strings is the reason we have problems, but characters
> are strings for other good reasons."  --Aahz
> http://mail.python.org/pipermail/python-3000/2006-April/000897.html
>
> Do you really want to give up Python's lovely string-slicing
> capabilities?
> --
> Aahz (aahz at pythoncraft.com)           <*>
> http://www.pythoncraft.com/
>
> "....Normal is what cuts off your sixth finger and your tail..."  --Siobhan
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100714/405837e0/attachment.html>


More information about the Python-list mailing list