简体   繁体   中英

what is the meaning of module name in imp.load_source?

There is a file named stock.py in d:\\stock.py,i can load it as

import imp
x=imp.load_source('module_name','d:\\stock.py')
x
<module 'module_name' from 'd:/stock.py'>

it can be written as :
y=imp.load_source('module','d:\\stock.py')
y
<module 'module' from 'd:/stock.py'>  

Any string can be used in arg of imp.load_source(arg,'d:\\stock.py'),what is the meaning of it then?

Any string can be used in arg of imp.load_source(arg,'d:\\stock.py'),what is the meaning of it then?

Using a sensible value makes errors and debugging easier to understand. Also, you could trigger __main__ blocks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM