Is there a better way of accessing functions in a module?
Ant
antroy at gmail.com
Tue Jun 13 13:06:38 EDT 2006
I have the following code which works fine for running some tests
defined within a module:
def a_test():
print "Test A"
def b_test():
print "Test B"
if __name__ == "__main__":
tests = ["%s()" % x for x in dir() if x.endswith("test")]
for test in tests:
eval(test)
But this feels like a hack... Is there a cleaner way for accessing the
functions of the current module similar to the __dict__ attribute of
classes? i.e. a way to access the local symbol table?
More information about the Python-list
mailing list