import locale locale setlocale(locale lc_all'english_united states ''english_united states conv locale localeconv(get mapping of conventions locale format("% "xgrouping=true' , , locale format_string("% * "(conv['currency_symbol']conv['frac_digits'] )grouping=true'$ , , templating the string module includes versatile template class with simplified syntax suitable for editing by end-users this allows users to customize their applications without having to alter the application the format uses placeholder names formed by with valid python identifiers (alphanumeric characters and underscoressurrounding the placeholder with braces allows it to be followed by more alphanumeric letters with no intervening spaces writing $creates single escaped $from string import template template('${village}folk send $$ to $cause ' substitute(village='nottingham'cause='the ditch fund''nottinghamfolk send $ to the ditch fund the substitute(method raises keyerror when placeholder is not supplied in dictionary or keyword argument for mail-merge style applicationsuser supplied data may be incomplete and the safe_substitute(method may be more appropriate -it will leave placeholders unchanged if data is missingt template('return the $item to $owner ' dict(item='unladen swallow' substitute(dtraceback (most recent call last)keyerror'ownert safe_substitute( 'return the unladen swallow to $owner template subclasses can specify custom delimiter for examplea batch renaming utility for photo browser may elect to use percent signs for placeholders such as the current dateimage sequence numberor file formatimport timeos path photofiles ['img_ jpg''img_ jpg''img_ jpg'class batchrename(template)delimiter '%fmt input('enter rename style (% -date % -seqnum % -format)enter rename style (% -date % -seqnum % -format)ashley_% % ' batchrename(fmtdate time strftime('% % % 'for ifilename in enumerate(photofiles)baseext os path splitext(filenamenewname substitute( =daten=if=ext(continues on next page brief tour of the standard library -part ii