jf...@ms4.hinet.net writes:

> For example,

(Please make the body of your message complete. The “Subject” field
should be a summary of your message's subject, and may not be read as
the first line of your message.)

> name = "test"  # test.py is a module's file
> import name

The standard library ‘importlib’ module exports an API for the import
machinery <URL:https://docs.python.org/3/library/importlib.html>.

You will likely want to use ‘importlib.import_module’
<URL:https://docs.python.org/3/library/importlib.html#importlib.import_module>.

-- 
 \      “The difference between a moral man and a man of honor is that |
  `\   the latter regrets a discreditable act, even when it has worked |
_o__)                   and he has not been caught.” —Henry L. Mencken |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to