Anders Lehmann  committed 822b0c1

Moved the __format__ method to the other magic methods

  • Participants
  • Parent commits c594afd
  • Branches default

Comments (0)

Files changed (1)

     def __nonzero__(self):
         return self.value != 0
+    def __format__(self, *args, **kw):
+        return "{1:{0}} {2}".format(args[0],self.value, self.unit)
     def convert(self, unit):
         """Change the unit and adjust the value such that the combination is
         equivalent to the original one. The new unit must be compatible with the
         return self.__class__(new_value, num + denom)
     # implementations of special functions, used by numpy ufuncs
-    def __format__(self, *args, **kw):
-        formatstring = "{1:{0}} {2}".format(args[0],self.value, self.unit)
-        return formatstring
     def sqrt(self):
         return pow(self, 0.5)