classes """return code for regenerating this instance ""return 'barometric({self })againwe can illustrate how it works in an interactive shellfrom tmp import barometric( print(bp exp(- * * /( * )) repr( 'barometric( ) eval(repr( )print( exp(- * * /( * )) the last two lines confirm that the repr method works as intendedsince running eval(repr(breturns an object identical to both __repr__ and __str__ return strings with information about an objectthe difference being that __str__ gives information to be read by humanswhereas the output of __repr__ is intended to be read by python how to know the contents of class sometimes listing the contents of class can be usefulparticularly for debugging consider the following dummy classwhich does nothing useful except to define doc stringa constructorand single attributeclass """ class for demo purposes ""def __init__(selfvalue)self value if we now write dir(awe see that the class actually contains great deal more than what we put into itsince python automatically defines certain methods and attributes in all classes most of the items listed are default versions of special methodswhich do nothing useful except to give the error message notimplemented if they are called howeverif we create an instance of aand use dir on that instancewe obtain more useful informationa ( dir( ['__class__''__delattr__''__dict__''__dir__''__doc__''__eq__''__format__''__ge__''__getattribute__''__gt__''__hash__''__init__''__init_subclass__''__le__''__lt__''__module__''__ne__''__new__''__reduce__''__reduce_ex__''__repr__''__setattr__''__sizeof__''__str__''__subclasshook__''__weakref__'' 'we see that the list contains the same (mostly uselessdefault versions of special methodsbut some of the items are more meaningful if we continue the interactive session to examine some of the itemswe obtain __doc__ ' class for demo purposes