You can use the subprocess
python module to achieve this.
import subprocess
cmd = "ifconfig | grep 'inet addr:' | grep -v 127.0.0.1 | cut -d: -f2 | awk '{ print $1}'"
co = subprocess.Popen([cmd], shell = True, stdout = subprocess.PIPE)
ips = co.stdout.read().strip().split("\n")
That should give you a list of IP addresses.
PS : It'll be better to use the following command instead
ifconfig | grep inet | grep -v inet6 | grep -v 127.0.0.1 | awk '{print $2}' | cut -d\: -f2 | cut -d\ -f1
This will exclude IPV6 addresses if any.
Pure Python Way
If you are looking to do this entirely in Python, then checkout netifaces python module.