sixteen appendix interactive mode error handling when an error occursthe interpreter prints an error message and stack trace in interactive modeit then returns to the primary promptwhen input came from fileit exits with nonzero exit status after printing the stack trace (exceptions handled by an except clause in try statement are not errors in this context some errors are unconditionally fatal and cause an exit with nonzero exitthis applies to internal inconsistencies and some cases of running out of memory all error messages are written to the standard error streamnormal output from executed commands is written to standard output typing the interrupt character (usually control- or deleteto the primary or secondary prompt cancels the input and returns to the primary prompt typing an interrupt while command is executing raises the keyboardinterrupt exceptionwhich may be handled by try statement executable python scripts on bsd'ish unix systemspython scripts can be made directly executablelike shell scriptsby putting the line #!/usr/bin/env python (assuming that the interpreter is on the user' pathat the beginning of the script and giving the file an executable mode the #must be the first two characters of the file on some platformsthis first line must end with unix-style line ending ('\ ')not windows ('\ \ 'line ending note that the hashor poundcharacter'#'is used to start comment in python the script can be given an executable modeor permissionusing the chmod command chmod + myscript py on windows systemsthere is no notion of an "executable modethe python installer automatically associates py files with python exe so that double-click on python file will run it as script the extension can also be pywin that casethe console window that normally appears is suppressed the interactive startup file when you use python interactivelyit is frequently handy to have some standard commands executed every time the interpreter is started you can do this by setting an environment variable named pythonstartup problem with the gnu readline package may prevent this