I am trying to figure out how to call a Python function from a shell script.

I have a Python file with multiple functions and I need to use the values returned by them in my shell script. Is there a way to do it.

I am doing this in order to read a config file using Python and getting the values in shell. Is there any other better way to achieve this.

test.py contains:

import ConfigParser

config = ConfigParser.ConfigParser()
config.read("test.conf")

def get_foo():
    return config.get("locations", "foo")

def get_bar():
    return config.get("locations", "bar")

I need to store the values returned by the Python functions in a shell variable.

Edit
Report