Fully Qualified name of a python module

ⅰ亾dé卋堺 提交于 2019-12-11 09:56:38

问题


In the code-base I am working on, the default python json module is being overridden by another json module which performs a different function.

How do I import the standard json module ?

import json does not work as it imports the other package.

What is the fully qualified name of the standard python json module ?


回答1:


Use absolute imports instead:

from __future__ import absolute_import
import json

You can still import the 'masking', local json module using the relative import syntax:

from . import json

Support for absolute imports as an option has been introduced in python 2.5, and is the default in python 3.

It'd be better to rename the 'masking' module, however.



来源:https://stackoverflow.com/questions/13697769/fully-qualified-name-of-a-python-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!