[Tutor] help
Steven D'Aprano
steve at pearwood.info
Thu Dec 27 13:45:18 CET 2012
On 27/12/12 23:07, Randy WhiteWolf wrote:
> # Sound the system bell
> print "\a"
That comment is misleading. \a does not necessarily sound the system
bell. Whether it does or not depends on the terminal you are using.
For example, under Linux I am using the "Konsole" terminal, and I
have four settings for the terminal bell:
* Off
* Flash the screen
* System notification
* Make a sound
except that the "make a sound" setting doesn't appear to work. Other
terminals may offer other choices, or no choice at all.
So chances are high that printing "\a" will not ring the system bell.
[...]
> raw_input ("\n\nPress the enter key to exit.")
>
>
> My problem is I hear no system bell; the enter doesn't respond by
>quitting the program; The problem with the program code the enter
>key hasn't worked in earlier programs.
The enter key thing will depend on how you are running the code.
If you are running the code inside an interactive environment, such
as IDLE or the default Python interactive interpreter, then the above
line of code does not exit. Just because it says "Press enter to exit"
doesn't make it exit! If it said "Press enter to become King of
England", you wouldn't expect that to happen would you? *wink*
However, when you run a script non-interactively, the script will exit
when it gets to end of the file. So if you add this line just before
the end:
raw_input("blah blah blah any message at all")
when Python reaches this line, it will pause until you hit the Enter
key, then it will reach the end of the script, then it will exit.
--
Steven
More information about the Tutor
mailing list