我有一個Python模塊命名的MIME類型,是相對於libx.something。這個mimetypes模塊包裝了python mimetypes模塊,但只在魔術模塊不存在的情況下。但是,當我的應用程序導入'libx.something.mimetypes'並且該模塊導入'mimetypes'時,它會導入自身,相對於'libx.something'。Python模塊進口本身,而不是DIST模塊
如何強制導入相對於蟒蛇DIST路徑,而不是當前模塊路徑工作,這樣我可以導入Python的MIME類型模塊?
File "/usr/local/lib/python2.7/dist-packages/libx/something/mimetypes.py", line 16, in get
return mimetypes.guess_type(path)
Error: 'module' object has no attribute 'guess_type'
但是......
$ python
Python 2.7.3 (default, Aug 1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mimetypes
>>> mimetypes.guess_type('a.txt')
('text/plain', None)