names and values of all instance attributes the dictionary' keys are sorted to finesse any ordering differences across python releases in these respectslistinstance is similar to ' attribute displayin factit' largely just variation on theme our class here uses two additional techniquesthoughit displays the instance' memory address by calling the id built-functionwhich returns any object' address (by definitiona unique object identifierwhich will be useful in later mutations of this codeit uses the pseudoprivate naming pattern for its worker method__attrnames as we learned earlier in this python automatically localizes any such name to its enclosing class by expanding the attribute name to include the class name (in this caseit becomes _listinstance__attrnamesthis holds true for both class attributes (like methodsand instance attributes attached to self as noted in ' first-cut versionthis behavior is useful in general tool like thisas it ensures that its names don' clash with any names used in its client subclasses because listinstance defines __str__ operator overloading methodinstances derived from this class display their attributes automatically when printedgiving bit more information than simple address here is the class in actionin single-inheritance modemixed in to the previous section' class (this code works the same in both python and xthough default repr displays use the label "instanceinstead of "object")from listinstance import listinstance class spam(listinstance)def __init__(self)self data 'foodx spam(print( <instance of spamaddress data =food inherit __str__ method print(and str(run __str__ you can also fetch and save the listing output as string without printing it with strand interactive echoes still use the default format because we're left __repr__ as an option for clientsdisplay str(xprint this to interpret escapes display ' designing with classes the __repr__ still is default