> --- Danny Yoo <[EMAIL PROTECTED]> wrote:
>
> > Ok, this makes sense.  Each passenger thread needs to know about the
> > queue, because that's the place you want the passenger to drop out of.
> >
> > Lists support a 'remove()' method, so you may be able to use it.
>
> Does it operate like queue.remove(self) ? Because the instance has no
> way of knowing its position in the queue.


Hello,

True, but if I have a bag of marbles, and I want to pick out a blue
marble, I don't have to know the exact position of the marble.  *grin*


###
>>> class Marble:
...     def __init__(self, color):
...         self.color = color
...     def __repr__(self):
...         return "Marble(%s)" % self.color
...
>>> bagOfMarbles = [Marble("red"), Marble("yellow"), Marble("blue"),
...                 Marble("green")]
>>> blueMarble = bagOfMarbles[2]
>>>
>>> bagOfMarbles.insert(0, Marble("black"))
>>>
>>> bagOfMarbles
[Marble(black), Marble(red), Marble(yellow), Marble(blue), Marble(green)]
>>> bagOfMarbles.remove(blueMarble)
>>>
>>> bagOfMarbles
[Marble(black), Marble(red), Marble(yellow), Marble(green)]
###


Hope this helps!

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to