bisect and Queue modules in Python 2.4
Abdullah Yoldas
apocode at gmail.com
Thu Mar 16 10:46:21 EST 2006
I had a similar problem when i was using asynchat.fifo, it had a list in the
past now it has a deque. So in order to put something to zeroth location (to
be compatible with python 2.3 and python 2.4) I did something like:
class fifo(asynchat.fifo):
def __init__(self, list=None):
asynchat.fifo.__init__(self, list)
self.have_deque = hasattr(self.list, 'appendleft')
def push_front(self, object):
if self.have_deque:
self.list.appendleft(object)
else:
self.list.insert(0, object)
Abdullah Yoldas
On 3/16/06, SA Trygubenko <sat39 at cam.ac.uk> wrote:
>
> Dear All,
>
> Python 2.4 (#1, Mar 22 2005, 21:42:42)
> [GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import Queue
> >>> q=Queue.Queue()
> >>> type(q.queue)
> <type 'collections.deque'>
> >>>
>
> q.queue used to be a list, and now it is something else?
>
> I was using bisect module to implement min priority queue, as described
> in python library reference (see
> http://www.python.org/doc/2.3.5/lib/bisect-example.html). I have found
> out that in Python 2.4 q.queue does not support "insert" anymore, which
> breaks bisect. Please help!
>
> Thank you,
> Semen
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060316/a8caa9d0/attachment.html>
More information about the Python-list
mailing list