string and text handling note that some of these constants (for exampleletters and uppercasewill vary depending on the locale settings of the system formatter objects the str format(method of strings is used to perform advanced string formatting operations as seen in "types and objects,and "operators and expressions,this method can access items of sequences or mappingsattributes of objectsand other kinds of related operations the string module defines class formatter that can be used to implement your own customized formatting operation this class exposes the pieces that implement the string formatting operation and allow you to customize them formatter(creates new formatter instance an instance of formatter supports the following operations format(format_string*args**kwargsformats the string format_string by defaultthe output is the same as calling format_string format(*args**kwargsfor examplef format("{nameis { :dyears old" ,name="dave"creates the string "dave is years oldf vformat(format_stringargskwargsa method that actually carries out the work of format(args is tuple of positional argumentsand kwargs is dictionary of keyword arguments this is faster method to use if you have already captured argument information in tuple and dictionary parse(format_stringa function that creates an iterator for parsing the contents of the format string format_string the iterator sweeps over the format string and produces tuples of the format (literal_textfield_nameformat_specconversionliteral_text is any literal text that precedes the next format specifier enclosed in braces it may be an empty string if there is no leading text field_name is string that specifies the field name in the format specifier for exampleif the specifier is '{ : }'then the field name is ' format_spec is the format specifier that appears after the colon--for example'din the previous example it will be an empty string if it wasn' specified conversion is string containing the conversion specifier (if anyin the previous exampleit is nonebut if the specifier was '{ ! : }'it would be set to 'sfield_nameformat_specand conversion will all be none for the last fragment of the format string get_field(fieldnameargskwargsextracts the value associated with given fieldname from args and kwargs fieldname is string such as " or "nameas returned by the parse(method shown previously returns tuple (valuekeywhere value is the field value and key is used to locate the value in args or kwargs if key is an integerit is an index in args if it is stringit is the key used in kwargs the fieldname may include additional indexing and attribute lookup such as ' nameor ' [name]in this casethe method lib fl ff