How can I get an already loaded module from a file path in Python? -


i have file paths inside directory , related module each python files.

python_file_suffix = u".py" element_name in os.listdir(path):     element_path = join(path, element_name)     if isfile(element_path):         if element_path.endswith(python_file_suffix):             # don't know module name here             module_name = "???"             source = imp.load_source(module_name, element_path)             # want methods of python file 

i don't think can use imp load file 2 reasons:

  • i not know module name
  • i not want load again module (if possible)

my ultimate goal methods information (name, docstring, ...) each file.

thank help.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -