The fact that you can use the backticks to run commands on the server itself is well documented both from a Ruby standpoint and a Heroku standpoint (several of their examples in their documentation use this method to execute a variety of commands).
As for using Python, like another poster said it's included in most Linux distros, and Heroku is really just running a Linux distro at the end of the day. I imagine that if you wanted to run a really simple script they wouldn't care, but I wouldn't build my whole app around it, because they can turn it off at any time.