For my purpose, I created a class that keeps an object.
The real length of that object is float, not integer. There can be 2 objects that differ by -- say .00001, and the shortest is the best for me.
For convenience I defined a __len__
method inside the class to be able to call len(obj).
However, python does not allow me for __len__
to return float, only integer.
I thought to return int(real_length * 10**K), for a given K.
Is there a better solution -- to work with floating point lengths of a class object?
EDIT:
In my class I have points in n-dimensional space, and I consider the distance between points, which is a real number, not an integer.
Could I make use of len function somehow ?