How to execute Python inline from a bash shell

Another way is to you use bash redirection:

python <<< 'print "Hi"'

And this works also with perl, ruby, and what not.

p.s.

To save quote ' and " for python code, we can build the block with EOF

c=`cat <<EOF
print(122)
EOF`
python -c "$c"

This works:

python -c 'print("Hi")'
Hi

From the manual, man python:

   -c command
          Specify  the command to execute (see next section).  This termi-
          nates the option list (following options are passed as arguments
          to the command).