【发布时间】:2014-06-09 10:49:00
【问题描述】:
我在 Eclipse PyDev 中有一个名为automated_vertica 的项目,其架构如下:
automated_vertica
src
root
__init__.py
RequestHandler.py
RequestHandler.py 是一个只有一堆方法的模块。
__init__.py 只包含两行:
from root import RequestHandler
print('test')
当我在 PyDev 中运行 __init__.py 时,Eclipse 控制台会读取两次 test。如果我删除from root,它就可以正常工作。
您能否解释一下我缺少什么以及这里发生了什么?
编辑:RequestHandler.py 的内容
'''
Created on Apr 23, 2014
@author: myname
'''
def FileToString(fileName):
f = open(fileName, 'r')
result = f.read()
f.close()
return result
def Flatten(listOfLists):
return [value for sublist in listOfLists for value in sublist]
【问题讨论】:
-
RequestHanlder.py中有什么内容? -
我已经添加了这个模块的内容
-
但即使是空模块,也会出现问题。
-
等一下。是
from root import...还是__init__.py还是init.py? -
__init__.py(当我在我的问题中输入它时它只是用粗体写的)
标签: python eclipse python-2.7 python-import