由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Python 如何自动import multiple files
相关主题
也问个python 问题谁能给个python 2 decorator class的例子?
new to python,问个stupid的问题程序结束时destructor被call的顺序是什么样的?
Python and C/C++ Question[c++] 关于构造函数的一个小问题
why I can not import Tkinter?C++里,Base Class如何调用Derived Class的method
C++ Q88: nested non-template class (转载)How to find out the memory layout of a class (转载)
如何从c# call python的class?怎么看java的源代码,谢谢
python 可以给class动态添加method吗?remove a module from cvs
windows 上安装python package.问个Python的问题
相关话题的讨论汇总
话题: import话题: baseclass话题: class话题: python话题: 自动
进入Programming版参与讨论
1 (共1页)
e*****r
发帖数: 700
1
Python 高手请帮忙看看如何实现自动import
我想import的情况如下:
有一些py文件定义了一些class,基本上都是一个class的子class,每个文件末端把那个
class initiate 加到一个list 里
比如:
file a.py:
from baseclass import *

classes=[]
class a(baseclass):
pass
classes.append(a)
file b.py:
from baseclass import *
class b(baseclass):
pass
classes.append(b)
我要实现的目的:
from a import *
from b import *
请问如何自动实现这些import? 这个folder里可能有不确定数量的py module.
谢谢
e*****r
发帖数: 700
2
试了一个code
for d in dlist:
globals()[d]=__import__(d)
可以满足我的需要,请问还有其他办法么?谢谢
1 (共1页)
进入Programming版参与讨论
相关主题
问个Python的问题C++ Q88: nested non-template class (转载)
判断Python程序员水平的一个试题如何从c# call python的class?
Anybody using Python?python 可以给class动态添加method吗?
Python的script的兼容问题windows 上安装python package.
也问个python 问题谁能给个python 2 decorator class的例子?
new to python,问个stupid的问题程序结束时destructor被call的顺序是什么样的?
Python and C/C++ Question[c++] 关于构造函数的一个小问题
why I can not import Tkinter?C++里,Base Class如何调用Derived Class的method
相关话题的讨论汇总
话题: import话题: baseclass话题: class话题: python话题: 自动