why does list's .remove() does not return an object?

David Stanek dstanek at dstanek.com
Thu May 17 15:29:56 EDT 2018


On 17-May-2018 12:37, Ned Batchelder wrote:
> On 5/17/18 12:28 PM, Dan Strohl via Python-list wrote:
> > On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote:
> > > I don't understand what this would return? x? You already have x.  Is
> > > it meant to make a copy? x has been mutated, so I don't understand the
> > > benefit of making a copy of the 1-less x.  Can you elaborate on the
> > > problem you are trying to solve?
> > >
> > > --Ned.
> > >
> > >
> > > assignment to another var
> > >
> > Though I don’t know what the OP was specifically looking for I could see a benefit to returning the item deleted.
>
> Notice that this is not the thing the OP wanted returned.  I believe they
> are looking to return the list, not the item.
>

I'm guessing that they want to be able to do some sort of method
chaining like:

  the_list.remove(x).remove(y)

Although the clarifying example was contrived and confusing. A more
concrete example would be greatly appreciated.

-- 
david stanek
web: https://dstanek.com
twitter: https://twitter.com/dstanek



More information about the Python-list mailing list