list.without()?
Magnus L. Hetland
mlh at vier.idi.ntnu.no
Tue Nov 16 05:06:15 EST 1999
"Fredrik Lundh" <fredrik at pythonware.com> writes:
> Magnus L. Hetland <mlh at vier.idi.ntnu.no> wrote:
> > Why on *earth* would you use a while/try/break-combination?
>
> maybe because the meaning of "without a
> specified element" is unclear. mike's version
> guarantees that:
>
> list.without(element)
> assert element not in list
>
> never fails, while your version behaves just
> like "remove" -- if there are several instances
> of an element value, only the first one is
> removed:
>
> count = list.count(element)
> list.without(element)
> assert count == 0 or list.count(element) == count-1
Oh - sorry about that. :)
My intended meaning was that implemented in my own routine, which made
me blind to the benefits of Mike's version. ;)
>
> in either case, adding "without" (like remove, but
> returns a new list) strikes me as being even more
> contrived than earlier proposals like "sorted" (like
> sort, but returns a new list), etc.
Okay... I don't think that is contrived either, but I guess we just
disagree ;)
>
> </F>
>
--
Magnus Echelon jamming noise:
Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism
Hetland Special Forces Delta Force AK47 Hillary Clinton
More information about the Python-list
mailing list