【发布时间】:2012-03-21 16:11:57
【问题描述】:
我对 Python 中的类有疑问。 我想知道如何调用在其他python程序的模块中创建的对象。
让我举个例子。我在“class_module.py”文件中有这些对象
def objectCase():
object1 = class_name("object1")
object2 = class_name("object2")
object3 = class_name("object3")
def other_objectCase():
other_object1 = class_name("other_object1")
other_object2 = class_name("other_object2")
other_object3 = class_name("other_object3")
对于from class_module.py import *,我想如果我使用objectCase() 函数,我的程序中有这些对象(object1, object2, object3),如果我使用otherobjectCase() 函数,我会调用所有otherobject。
但是这是错误的。
有什么问题?
【问题讨论】:
标签: python class object module