pair of html escape codes because printing each code snippet effectively embeds it in the html response streamwe must escape any special html characters it contains html parsers (including python' standard html parser module presented in translate escape codes back to the original characters when page is rendered more generallybecause cgi is based upon the notion of passing formatted strings across the netescaping special characters is ubiquitous operation cgi scripts almost always need to escape text generated as part of the reply to be safe for instanceif we send back arbitrary text input from user or read from data source on the serverwe usually can' be sure whether it will contain html charactersso we must escape it just in case in later exampleswe'll also find that characters inserted into url address strings generated by our scripts may need to be escaped as well literal in url is specialfor exampleand must be escaped if it appears embedded in text we insert into url howeverurl syntax reserves different special characters than html codeand so different escaping conventions and tools must be used as we'll see later in this cgi escape implements escape translations in html codebut urllib parse quote (and its relativesescapes characters in url strings mocking up form inputs here againform inputs are "mocked up(simulated)both for debugging and for responding to request for all languages in the table if the script' global debugme variable is set to true valuefor instancethe script creates dictionary that is plug-and-play compatible with the result of cgi fieldstorage call--its "languageskey references an instance of the dummy mock-up class this class in turn creates an object that has the same interface as the contents of cgi field storage result--it makes an object with value attribute set to passed-in string the net effect is that we can test this script by running it from the system command linethe generated dictionary fools the script into thinking it was invoked by browser over the net similarlyif the requested language name is "all,the script iterates over all entries in the languages tablemaking mocked-up form dictionary for each (as though the user had requested each language in turnthis lets us reuse the existing showhello logic to display each language' code in single page as always in pythonobject interfaces and protocols are what we usually code fornot specific datatypes the showhello function will happily process any object that responds to the syntax form['language'value notice that #if you are reading closelyyou might notice that this is the second time we've used mock-ups in this (see the earlier tutor cgi exampleif you find this technique generally usefulit would probably make sense to put the dummy classalong with function for populating form dictionary on demandinto module so that it can be reused in factwe will do that in the next section even for two-line classes like thistyping the same code the third time around will do much to convince you of the power of code reuse the hello world selector