[Python-ideas] list.pop() accepting a list of integers as argument

pedro santos probiner at gmail.com
Thu Mar 26 07:58:57 CET 2015


Hi Ron
Wasn't looking for the n items from the end but good to know.

Cheers


On Thu, Mar 26, 2015 at 3:36 AM, Ron Adam <ron3200 at gmail.com> wrote:

>
>
> On 03/25/2015 09:45 PM, pedro santos wrote:
>
>> Is this best way to remove multiple items from a list?
>> Because if so I think passing a list of integers through pop would be
>> cleaner.
>>
>
> This is probably the fastest way to remove N items from the end.
>
> >>> L = list("123456789")
> >>> L
> ['1', '2', '3', '4', '5', '6', '7', '8', '9']
> >>> L[-3:] = []
> >>> L
> ['1', '2', '3', '4', '5', '6']
>
> Cheers,
>    Ron
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 




*------------------------------[image:
http://i153.photobucket.com/albums/s202/animatics/probiner-sig.gif]Pedro
Alpiarça dos Santos Animator  3DModeler  Illustrator >>
http://probiner.x10.mx/ <http://probiner.x10.mx/>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150326/0756bf47/attachment.html>


More information about the Python-ideas mailing list