object-oriented programming we have created an eval()-able representational form for examplegiven fuzzybool fuzzybool )repr(fwill produce the string 'fuzzybool( )all objects have some special attributes automatically supplied by pythonone of which is called __class__a reference to the object' class all classes have private __name__ attributeagain provided automatically we have used these attributes to provide the class name used for the representation form this means that if the fuzzybool class is subclassed just to add extra methodsthe inherited __repr__(method will work correctly without needing to be reimplementedsince it will pick up the subclass' class name def __str__(self)return str(self __valuefor the string form we just return the floating-point value formatted as string we don' have to use super(to avoid infinite recursion because we call str(on the self __value attributenot on the instance itself def __bool__(self)return self __value def __int__(self)return round(self __valuedef __float__(self)return self __value the __bool__(special method converts the instance to booleanso it must always return either true or false the __int__(special method provides integer conversion we have used the built-in round(function because int(simply truncates (so would return for any fuzzybool value except floating-point conversion is easy because the value is already floating-point number def __lt__(selfother)return self __value other __value def __eq__(selfother)return self __value =other __value to provide the complete set of comparisons (=>it is necessary to implement at least three of themfrom from <we have shown only two representative methods here since all of them are very similar def __hash__(self)return hash(id(self)in factwe implemented only the __lt__(and __eq__(methods quoted here--the other comparison methods were automatically generatedwe will see how in complete comparisons