There are 2 slightly different things that you might want to do
execute a script xxx.py from your main program. This can be done with exec open("xxx.py").read()
import xxx.py as a module, which is done with import xxx or mod = __import__("xxx")
If you import the module, the script xxx.py is only executed the first time the module is imported, and a module object is stored in sys.modules["xxx"] .
If you choose the exec solution, a good idea is to execute the script in a separate dictionary to avoid polluting your namespace, like this
mydict = dict()
exec open("xxx.py").read() in mydict
# or in python 3: exec(open("xxx.py").read(), mydict)
It is unusual to choose a module to import through interaction with the user. A more logical way is that the user chooses an action to execute and this choice results in selecting a function to call. For example
action = raw_input("what should I do ? ").strip()
if action == "go to hell":
elif action == "quit":
hi i am using vb.net multidimensional arrays and i am getting the nearest or closest number i just want to ask if my code was correct or not ? for example i have an input of 13000 and nearest number should be on col 6 can you please help me ...
write a C++ program which take inputs from the user/keyboard and calculate his ZAKAT.
get the input from user may include
-Amount invested in business
-Amount given to other business partners as loan
-Amount payable to others