Andy Buckley <a...@insectnation.org> added the comment:

Maybe I just value method symmetry/equivalence higher than the designers when 
it comes to interface expectations. I've seen several "I expected there to be a 
prepend() method like append() on lists, but there isn't -- what do I do?" 
emails on list archives when searching for info on this, which I think is in 
itself a hint that the current situation is counter-intuitive.

The argument that "there are already two ways to do it, so why add a third?", 
is not bad, but if applied to appending, it would ban the append() method... 
except that it's already there. Personally, the behaviour of append() is very 
familiar, while insert(0, ...) is less-used and I always have to explicitly 
confirm to myself that it isn't going to overwrite the zeroth existing element. 
Adding a prepend(x) method which just calls insert(0, x) (or calls the same 
underlying C function) would change nothing in terms of code efficiency -- bad 
programmers will always write inefficient code, one way or another -- but would 
make the list API more intuitive and improve code readability: seems to me like 
the sort of thing that Python is philosophically into ;)

Sorry to bring up this issue that I guess has been raised (many times?) before, 
but I thought I'd have a stab at a convincing case!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9080>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to