Calling a python function from bash script


Question

I have an "alarm email" function inside a python module. I want to be able to call this function from a bash script. I know you can call a module using 'python ' in the script, but I'm not if you can or how you would call a specific function within the module.

1
18
1/22/2010 9:33:17 PM

Accepted Answer

python -c'import themodule; themodule.thefunction("boo!")'
42
1/22/2010 7:04:19 PM

You can use the -c option:

python -c "import random; print random.uniform(0, 1)"

Modify as you need.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon