Say there is the following function in a file called fb_auth_token.py
def get_fb_access_token(email, password):
...
return ...
How would I run this from bash? python fb_auth_token.py get_fb_access?. How do I call just the one specific function?
Say there is the following function in a file called fb_auth_token.py
def get_fb_access_token(email, password):
...
return ...
How would I run this from bash? python fb_auth_token.py get_fb_access?. How do I call just the one specific function?
You could either call python with the command option:
python -c "from file_name import function;function()"
or if you want this function to be called every time you execute the script you could add the line
if __name__ == "__main__":
function()
This will then only execute this function if the file is executed directly (i.e. you can still import it into another script without "function" being called).
I figured it out:
python -c 'import fb_auth_token; print fb_auth_token.get_fb_access_token("email", "password")'
You can use the -c command line argument. For example:
python -c 'import fb_auth_token; fb_auth_token.get_fb_access_token("email", "password")'