我在多个文件中有多个类。例如
文件1:
class gen_list ():
def gen_list_spice(self):
...
文件2:
class gen_postsim ():
def gen_postsim(self):
...
我想用另一个类似这样的类来包装它
class char ()
def __init__ (self, type):
if (type == list):
....... (load gen_list only<-- this part i do not know how to write)
else
....... (load both)
在顶部包装中,我想举例来说,如果我给出list
,我将能够使用gen_list_spice
,否则,当我只需要调用对象char
时,我将能够同时使用gen_list_spice
和gen_postsim
我不知道你为什么这样做,但你可以导入文件的任何部分。你知道吗
文件1应命名为
get_list.py
文件2应命名为
gen_postsim.py
在包装文件中:
但这不是一个好的做法。您可以使用函数而不是类,并在文件头中导入它们。你知道吗
在文件
gen_list.py
在文件
gen_postsim.py
在包装文件中
相关问题 更多 >
编程相关推荐