Just noticed that there is no function in Python to remove an item in a list by index, to be used while chaining.
For instance, I am looking for something like this:
another_list = list_of_items.remove[item-index]
instead of
del list_of_items[item_index]
Since, remove(item_in_list)
returns the list after removing the item_in_list
; I wonder why a similar function for index is left out. It seems very obvious and trivial to have been included, feels there is a reason to skip it.
Any thoughts on why such a function is unavailable?
----- EDIT -------
list_of_items.pop(item_at_index)
is not suitable as it doesn't return the list without the specific item to remove, hence can't be used to chain. (As per the Docs: L.pop([index]) -> item -- remove and return item at index)
None
, never the altered object. Why do you expect to be able to chain when standard Python mutable types don't offer this anywhere else? – Somberremove()
exists. It returns the altered object. – Guarantylist.remove()
returnsNone
, not the altered sequence. See ideone.com/mEH1LL – Somber