how to get a beep, OS independent ?

Duncan Booth duncan.booth at invalid.invalid
Mon Dec 8 04:10:35 EST 2008


Joe Strout <joe at strout.net> wrote:

> But invoking the standard system beep is such a basic function that it  
> ought to be easier than this.  I'm pretty sure it's a single OS call  
> on all platforms.  On OS X, for example, it's
> 
>    void NSBeep(void);
> 
> declared in NSGraphics.h.  I'm sure it's something similarly simple on  
> other platforms.

I think what you're missing is a definition for 'the standard system'. If 
I'm logged in to one of my servers in a large datacentre then I don't what 
that system to beep as that would be pretty useless. I want the system I'm 
logged in with to do the beeping.

For some systems and some types of login (e.g. Microsoft's Remote Desktop) 
then remoting the sound output isn't a problem, but I might just be logged 
in with SSH and in that case the only option available is to send some 
escape sequence to the user's terminal. Traditionally generation of escape 
sequences for a user's terminal is something done by the application, not a 
function of the operating system.

I think that's why you'll find there will be a variety of ways to generate 
beeps, squeaks and squawks if you are using a gui (only as with all other 
gui functions there is no common ground between different systems), but 
nothing beyond '\a' for terminals.

-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list