我有一个我在Python2中编写的简单包。我已经为Python3做了必要的语法更改(即只是print语句)。结构如下:
my_only_module/
__init__.py
my_only_module.py
my_only_module.py
内部是:
import requests
import some_other_standard_lib
# basic class gets overwritten
class Basic(object):
def basic_function():
# advanced1 class inherits Basic class.
class Advanced1(Basic):
def advanced_function():
...
# advanced2 class inherits Basic class.
class Advanced2(Basic):
def advanced_function():
...
__init__.py
有:
from my_only_module import *
这一切都像这样工作(在Pyhton2.7中安装后):
from my_only_module import Advanced1
a_one = Advanced1()
from my_only_module import Advanced2
a_two = Advanced2()
但在Python 3.4中,它失败并显示以下消息:
ImportError:无法导入名称“Advanced2”
任何想法都会受到赞赏。