List operation: Removing an item

Terry Reedy tjreedy at udel.edu
Sun Apr 16 19:54:23 EDT 2006


"Steven D'Aprano" <steve at REMOVETHIScyber.com.au> wrote in message 
news:pan.2006.04.16.13.31.34.683427 at REMOVETHIScyber.com.au...
> On Sun, 16 Apr 2006 01:37:44 -0400, Terry Reedy wrote:
>> Do you really need the items sorted?  I strongly suspect that a set 
>> would
>> work better.  Much easier to randomly add, delete, and check membership.
>
> The OP didn't say anything about having the items sorted.

Which, along with the specification of unique members, is why I questioned 
the wisdom of using a list which is sorted and does allow duplicates.

> I think he's trying to learn how to use Python, as he says, and
> specifically learn about lists at this moment. Telling him to use sets
> isn't going to help him learn about lists.

Learning about how to use any particular type includes learning when to use 
it and just as importantly, when not to use it.  The OP's difficulties seem 
to me to stem from not using the right type.  It would have been a 
disservice to him for nobody to mention that and steer him in a better 
direction.

Terry Jan Reedy






More information about the Python-list mailing list