def __init__(selfstr)self value str import cgisys if debugmeform {inputkeydummy(sys argv[ ])elseform cgi fieldstorage(print('content-typetext/html\ 'print('languages'print('syntax'mocked-up input obj name on cmd line parse real inputs adds blank line def showhello(form)html for one language choice form[inputkeyvalue print('%schoicetryprint(cgi escape(hellos[choice])except keyerrorprint("sorry-- don' know that language"print(''if not inputkey in form or form[inputkeyvalue ='all'for lang in hellos keys()mock {inputkeydummy(lang)showhello(mockelseshowhello(formprint(''and as usualthis script prints html code to the standard output stream to produce response page in the client' browser not much is new to speak of in this scriptbut it employs few techniques that merit special focusraw strings and quotes notice the use of raw strings (string constants preceded by an "rcharacterin the language syntax dictionary recall that raw strings retain backslash characters in the string literallyinstead of interpreting them as string escape-code introductions without themthe \ newline character sequences in some of the language' code snippets would be interpreted by python as line feedsinstead of being printed in the html reply as \ the code also uses double quotes for strings that embed an unescaped single-quote characterper python' normal string rules escaping text embedded in html and urls this script takes care to format the text of each language' code snippet with the cgi escape utility function this standard python utility automatically translates characters that are special in html into html escape code sequencesso that they are not treated as html operators by browsers formallycgi escape translates characters to escape code sequencesaccording to the standard html conventionand become &lt;&gt;and &ampif you pass second true argumentthe double-quote character ("is translated to &quot server-side scripting