Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How to call Python module from command line?

I have a python script like this

def fubar():
     #do something useful

How do I use this script as a python module from command line?


1 Answer
Rajendra Dharmkar

If we are writing a Python script that is to be used as a module, we can test this module by adding this call of the function to the bottom:

def fubar():
    #does something useful
fubar()

and run it  at the command prompt like this:

~$ python fubar.py
Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.