This is a module named XYZ.
def func(x)
.....
.....
if __name__=="__main__":
print func(sys.argv[1])
Now I have imported this module in another code and want to use the func. How can i use it?
import XYZ
After this, where to give the argument, and syntax on how to call it, please?
The following will bring the name
funcinto your current namespace so you can use it directly without the module prefix:You can also import the module and call the function using its fully qualified name:
There are a couple of other options as well, for more details read the definitive article on Importing Python Modules