python - Typerror: unorderable types -


I am writing a class for temperature and I am trying to compare if temp1 & gt; temp2 and so on.

This function is part of the code for one of the definitions that is supposed to handle expectations.

  def __eq __ (self, others): if self .__ valid == truth and other __valid == true: if self .__ scale == other .__ scale: if self .___ world == Other .__ mag: Return is true: return false # if itself .___ Jag ​​and gt; Other .__ mag: #return True #else: #return False #if self .___ World & gt; = Other .__ mag: #return True #se: #Rurn False else: if self .__ scale == "C": A = other. Celsius () if it is itself .__ mag == a .__ mag: return is true Return: If wrong, self .__ scale == "F": B = Other FerronHet () if self .__ mag == B.__ mag: Return is true: return incorrect: return incorrect   

but when I do:

  A = Temperature (37.0, "C") & lt; Br> B = Temperature (30.0, "C") & lt; Br> Print (A & gt; B)   

I get an error:

  Traceback (most recent call final): File "C: \ User \ owner \ desktop \ Temperature.py ", line 218, & lt; Module & gt; Print (A> B) Type Error: Irreversible Type: Temperature ()> Temperature ()   

I am trying to compare the magnitudes of two, but this is an ongoing issue.

__ eq __ () only controls equality tests You < Code> __ take__ () ("a ?? ¤") and want to define friends.

You can use automatically to define other inequality operators.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -