[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: import queue in Python 2 and Python 3
From:       Thomas Jollans <tjol () tjol ! eu>
Date:       2017-06-30 8:34:43
Message-ID: 59560d30$0$1822$e4fe514c () news ! kpn ! nl
[Download RAW message or body]

On 30/06/17 06:06, Benjamin Chaney wrote:
> What is the best way to import the synchronized queue class that is
> compatible with both Python2 and Python3. Right now I am using the
> following:
> 
>> if sys.version_info < (3, 0):
>>    import Queue as queue
>> else:
>>    import queue
> 
> This seems somewhat unpythonic. Is there a better way without
> installing extra packages?

What Chris said. If you find yourself doing a lot of this kind of thing,
you might want to use six, though, and do

from six.moves import queue

-- 
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic