I am importing a function - func, from a module - mod, using
from mod import func
And using it as
X=func(x,y)
but before executing the function my program is executing the whole module. How do I make it to execute only the function?
If you want to avoid module execution put the code in the module under main
# stuff to run always here such as class/def
def main():
pass
if __name__ == "__main__":
# stuff only to run when not called via 'import' here
main()
more complete answer: Why is Python running my module when I import it, and how do I stop it?