You can use heredoc if you want to keep the source of both bash and python scripts together. For example, say the following are the contents of a file called pyinbash.sh:
#!/bin/bash
echo "Executing a bash statement"
export bashvar=100
cat << EOF > pyscript.py
#!/usr/bin/python
import subprocess
print 'Hello python'
subprocess.call(["echo","$bashvar"])
EOF
chmod 755 pyscript.py
./pyscript.py
Now running the pyinbash.sh will yield:
$ chmod 755 pyinbash.sh
$ ./pyinbash.sh
Exe