[Python-ideas] New list methods

George Sakkis george.sakkis at gmail.com
Tue May 5 19:46:57 CEST 2009


On Tue, May 5, 2009 at 1:11 PM, Jeremy Banks <jeremy at jeremybanks.ca> wrote:

> I believe the proposal is to have l.rremove() take a value parameter,
> and remove the last occurrence of that value from the list, not just
> the last value in the list.
>
> My assumpting is that their basic functionality would work like this.
>
>    l = [1, 2, 3, 2, 1]
>    l.rindex(2) == 3
>    l.rremove(2)
>    l == [1, 2, 3, 1]
>
> I'd say +1.

The functionality would be useful but instead of polluting the API
with various "r*" methods, I'd prefer a `reversed=False` boolean
parameter wherever it makes sense, just like sort(ed). I.e. instead of
list.rindex -> list.index(reversed=True) and list.rremove ->
list.remove(reversed=True).

George



More information about the Python-ideas mailing list