carries out the extra lookup and returns the appropriate value howeverthe value of key in the returned tuple is just set to ' get_value(keyargskwargsextracts the object from args or kwargs corresponding to key if key is an integerthe object is taken from args if it is stringit is taken from kwargs check_unused_args(used_argsargskwargschecks for unused arguments in the format(operation used_args is set of all of the used argument keys (see get_field()that were found in the format string args and kwargs are the positional and keyword arguments passed to format(the default behavior is to raise typeerror for unused arguments format_value(valueformat_specformats single value according to the given format specification by defaultthis simply executes the built-in function format(valueformat_specf convert_field(valueconversionconverts value returned by get_field(according to the specified conversion code if conversion is nonevalue is returned unmodified if conversion is 'sor ' 'value is converted to string using str(or repr()respectively if you want to create your own customized string formattingyou can create formatter object and simply use the default methods to carry out the formatting as you wish it is also possible to define new class that inherits from formatter and reimplements any of the methods shown earlier for details on the syntax of format specifiers and advanced string formattingrefer to and template strings the string module defines new string typetemplatethat simplifies certain string substitutions an example can be found in the following creates new template string objecttemplate(sheres is string and template is defined as class template objecttsupports the following methodst substitute( [**kwargs]this method takes mapping objectm (for examplea dictionary)or list of keyword arguments and performs keyword substitution on the string this substitution replaces the string '$$with single '$and the strings '$keyor '${key}with ['key'or kwargs['key'if keyword arguments were supplied key must spell valid python identifier if the final string contains any unresolved '$keypatternsa keyerror exception is raised safe_substitute( [**kwargs]the same as substitute(except that no exceptions or errors will be generated insteadunresolved $key references will be left in the string unmodified lib fl ff