Can't get around "IndexError: list index out of range"
Steve Holden
steve at holdenweb.com
Sun Oct 8 16:05:07 EDT 2006
MonkeeSage wrote:
> 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-
>>ful.
>
>
> 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
> are:
>
> Reason: It's unnecessary / bloat.
> - Then the same thing is true of the dict methods.
>
No: you are proposing to add features to the sequence interface for
which there are few demonstrable use cases.
> Reason: It's not useful.
> - I know of several use cases and could probably find others.
>
Well I certainly didn't find your last one particularly convincing: the
attempt to reference a non-existent sequence member is almost always a
programming error.
> 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.
>
I would argue exactly the opposite: the reason why they shouldn't be
implemented is because no good reason has been presented why they *should*.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list
mailing list