strings the latter makes them applicable to arbitrarily encoded unicode textsimply because the str type is unicode texteven if it' only ascii these methods originally appeared as function in the string modulebut are only object methods todaythe string module is still present because it contains predefined constants ( string ascii_uppercase)as well as the template substitution interface in and later--one of the techniques discussed in the next section templating with replacements and formats by way of reviewlet' take quick look at string methods in the context of some of their most common use cases as we saw when generating html forwarding pages in the string replace method is often adequate by itself as string templating tool--we can compute values and insert them at fixed positions in string with simple replacement callstemplate '---$target ---$target ---val 'spamval 'shrubberytemplate template replace('$target 'val template template replace('$target 'val template '---spam---shrubbery---as we also saw when generating html reply pages in the cgi scripts of and the string formatting operator is also powerful templating toolespecially when combined with dictionaries--simply fill out dictionary with values and apply multiple substitutions to the html string all at oncetemplate ""----%(key ) ----%(key ) -""vals {vals['key ''spamvals['key ''shrubberyprint(template valsspamshrubbery--beginning with python the string module' template feature is essentially simplified and limited variation of the dictionary-based format scheme just shownbut it allows some additional call patterns which some may consider simplervals {'key ''shrubbery''key ''spam' text and language