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

2018-05-17 Thread Abdur-Rahmaan Janhangeer
ah there's no return question then that precisely returned the discussion to the first answer Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ On Thu, 17 May 2018, 23:35 Tobiah, wrote: > On 05/17/2018 09:25 AM, Ned Batchelder wrote: > > On 5/17/18 11:57 AM,

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

2018-05-17 Thread Karsten Hilbert
>new_list = list(x.remove(0)) >new_list = x.remove(0)[:] Please disregard :) kh -- https://mail.python.org/mailman/listinfo/python-list

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

2018-05-17 Thread Ian Kelly
On Thu, May 17, 2018 at 3:27 PM, Karsten Hilbert wrote: >> On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote: >> > x = [0,1] >> > x.remove(0) >> > new_list = x >> > >> > instead i want in one go >> > >> > x = [0,1] >> > new_list = x.remove(0) # here a way for it to

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

2018-05-17 Thread Karsten Hilbert
> On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote: > > x = [0,1] > > x.remove(0) > > new_list = x > > > > instead i want in one go > > > > x = [0,1] > > new_list = x.remove(0) # here a way for it to return the modified list by > > adding a .return() maybe ? > > There isn't a way to do that in

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

2018-05-17 Thread Tobiah
On 05/17/2018 09:25 AM, Ned Batchelder wrote: On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote: x = [0,1] x.remove(0) new_list = x Just call the original list 'new_list' to begin with. new_list = [0, 1] new_list.remove(0) There you are! --

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

2018-05-17 Thread David Stanek
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

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

2018-05-17 Thread Ned Batchelder
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.

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

2018-05-17 Thread Dan Strohl via Python-list
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

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

2018-05-17 Thread Ned Batchelder
On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote: x = [0,1] x.remove(0) new_list = x instead i want in one go x = [0,1] new_list = x.remove(0) # here a way for it to return the modified list by adding a .return() maybe ? There isn't a way to do that in one line.  I often find myself

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

2018-05-17 Thread Abdur-Rahmaan Janhangeer
x = [0,1] x.remove(0) new_list = x instead i want in one go x = [0,1] new_list = x.remove(0) # here a way for it to return the modified list by adding a .return() maybe ? Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ On Thu, 17 May 2018, 19:54 Alexandre Brault,

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

2018-05-17 Thread Alexandre Brault
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

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

2018-05-17 Thread Abdur-Rahmaan Janhangeer
On Thu, 17 May 2018, 18:55 Ned Batchelder, wrote: > On 5/17/18 4:23 AM, Abdur-Rahmaan Janhangeer wrote: > > if then a more convenient way might be found to naturally remove and > return the list > > maybe it was not included as one might want to remove the list only > > x

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

2018-05-17 Thread Ned Batchelder
On 5/17/18 4:23 AM, Abdur-Rahmaan Janhangeer wrote: if then a more convenient way might be found to naturally remove and return the list maybe it was not included as one might want to remove the list only x = [1] x.remove(1) as opposed to x = [1] x.remove(1) new_list = x i was looking for

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

2018-05-17 Thread Jach Fong
Abdur-Rahmaan Janhangeer at 2018/5/17 PM 04:23 wrote: if then a more convenient way might be found to naturally remove and return the list maybe it was not included as one might want to remove the list only x = [1] x.remove(1) as opposed to x = [1] x.remove(1) new_list = x IMO, this way is

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

2018-05-17 Thread Abdur-Rahmaan Janhangeer
if then a more convenient way might be found to naturally remove and return the list maybe it was not included as one might want to remove the list only x = [1] x.remove(1) as opposed to x = [1] x.remove(1) new_list = x i was looking for like x = [1] x.remove(1).return() ps. list is was

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

2018-05-16 Thread jladasky
On Wednesday, May 16, 2018 at 7:42:01 PM UTC-7, Abdur-Rahmaan Janhangeer wrote: > why is x = list.remove(elem) not return the list? > > Abdur-Rahmaan Janhangeer > https://github.com/Abdur-rahmaanJ 1) If you are naming your list "list," you're asking for trouble. Shadowing builtin names is

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

2018-05-16 Thread Ned Batchelder
On 5/16/18 10:41 PM, Abdur-Rahmaan Janhangeer wrote: why is x = list.remove(elem) not return the list? Methods in Python usually do one of two things: 1) mutate the object and return None; or 2) leave the object alone and return a new object.  This helps make it clear which methods mutate