Seems like I want a pre-processor, but...

Carl Banks invalidemail at aerojockey.com
Wed Mar 29 15:37:48 CEST 2006


Russell Warren wrote:
> > the collections module was added in 2.4
>
> Ah... sorry about that.  I should have checked my example more closely.
> What I'm actually doing is rebinding some Queue.Queue behaviour in a
> "safe" location like this:
>
> def _get(self):
>   ret = self.queue.popleft()
>   DoSomethingSimple()
>   return ret

What you should have done is call the base class's _get method, like
this:

def _get(self):
    ret = Queue._get(self)
    DoSomethingSimple()
    return ret

This'll work in 2.3, 2.4, and if they were to change the type of the
queue again in 2.5, it would still work without any changes.  Don't
redo the work the base class does if you don't have to.


Carl Banks




More information about the Python-list mailing list