如何在python 3中导入我自己的队列

时间:2017-07-14 21:50:46

标签: python python-3.x

我正在将Java程序(Queue.java)翻译成python程序( queue.py )。 queue.py无法在python 3中的测试代码中导入,因为它与内置的queue模块冲突。因此导入了内置queue

我知道如果我将queue.py更改为任何其他名称,它会起作用。但是,为了清楚起见,我想向观众展示Queue.java - > queue.py。所以我想知道是否有办法在python 3中保留名称。

这是git repo,其中queue.py在python 3中成为一个问题。这是travis test失败的地方。 queue.py和test_all.py位于同一目录中。以下是我调试它的方法:

$ nosetests test_all.py:test_queue --pdb
> /Users/jaska/example_code_in_python/test_all.py(83)_verify_module()
-> assert len(params) > 0
(Pdb) print(params)
[]
(Pdb) print(module.__doc__)
A multi-producer, multi-consumer queue.
(Pdb) dir(module)
['Empty', 'Full', 'LifoQueue', 'PriorityQueue', 'Queue', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'deque', 'heappop', 'heappush', 'threading', 'time']

0 个答案:

没有答案