Can't get around "IndexError: list index out of range"
MonkeeSage at gmail.com
Sun Oct 8 21:24:33 CEST 2006
On Oct 8, 1:44 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> but "let's hypergeneralize and treat sequences and mappings as the same
> thing" proposals are nothing new; a trip to the archives might be help-
Huh? I don't want to treat sequences and mappings as the same thing.
I'm talking about adding two similar convenience methods for sequences
as already exist for mappings. That may make the two APIs closer, but
that's not necessarily a bad thing (think the square-bracket accessor).
Besides, has_index is sufficiently different already. If it's really a
problem, change get() to at() for sequences. seq.at(2).
So far the reasons offered against adding those convenience methods
Reason: It's unnecessary / bloat.
- Then the same thing is true of the dict methods.
Reason: It's not useful.
- I know of several use cases and could probably find others.
Reason: It takes effort to implement it. Why don't you do it yourself
if it's such a great idea!
- Mabye I will. But that is only a reason why they aren't currently
implemented, not why they *shouldn't* be.
Reason: It makes sequences and mapping to much alike.
- Then change the names for the sequences methods.
That is to say, no good reason has been offered for why these methods
shouldn't be implemented.
More information about the Python-list