The cross-platform way to do this is print '\a' . This will send the ASCII Bell character to stdout and, hopefully, will generate a beep (a for "alert"). Please note that many modern terminal emulators provide the ability to ignore bell characters.
Since you are on Windows, you will be happy to hear that Windows has its own (attach itself) Beep API, which allows you to send audio signals of arbitrary length and pitch. Note that this solution is for Windows only, so you should probably prefer print '\a' if you really don't care about Hertz and milliseconds.
The Beep API is accessed through the winsound module: http://docs.python.org/library/winsound.html
jforberg Jun 30 '11 at 15:59 2011-06-30 15:59
source share