Comparisons and sorting of a numeric class....
rosuav at gmail.com
Fri Jan 23 19:03:48 CET 2015
On Sat, Jan 24, 2015 at 4:45 AM, Rustom Mody <rustompmody at gmail.com> wrote:
> No disagreement with the 'hack'
> As for "no use case for equal but distinct tokens" - thats a strange
> view given this thread
Look at it this way: A classic enumeration has no use-case for
equal-but-distinct; this thread doesn't disagree with that, because
this thread is not about classic enumerations. In the same way,
integers don't have use-cases for equal-but-distinct either, but in
practice, you can distinguish between exact literals and the results
rosuav at sikorsky:~$ cat unique_numbers.py
x = 100000
y = 100000
z = 99999+1
print(x is y, x is z, y is z)
rosuav at sikorsky:~$ python3 unique_numbers.py
True False False
This is still not good code, though. If you really need to distinguish
those, your code is majorly fragile.
More information about the Python-list