Some simple usage examples:: |
Some simple usage examples:: |
|
|
>>> from peak.util.extremes import Min, Max |
>>> from peak.util.extremes import Min, Max |
>>> import sys |
>>> try: |
|
... from sys import maxint |
|
... except ImportError: |
|
... maxint = (1<<64) |
|
|
>>> Min < -(1<<31) |
>>> Min < -maxint |
True |
True |
>>> Min < None |
>>> Min < None |
True |
True |
>>> Min < '' |
>>> Min < '' |
True |
True |
>>> Max > (1<<31) |
>>> Max > maxint |
True |
True |
>>> Max > 99999999999999999 |
>>> Max > 99999999999999999 |
True |
True |
|
|
The ``Min`` object compares less than any other object but itself, while the |
The ``Min`` object compares less than any other object but itself, while the |
``Max`` object compares greater than any other object but itself. Both are |
``Max`` object compares greater than any other object but itself. Both are |
instances of the ``Extreme`` type. |
instances of the ``Extreme`` type, are hashable, and can be used as |
|
dictionary keys: |
|
|
|
>>> x = {Min: 1, Max: 2} |
|
|
While the original PEP 326 implementation of these extreme values is shorter |
While the original PEP 326 implementation of these extreme values is shorter |
than the version used here, it contains a flaw: it does not correctly handle |
than the version used here, it contains a flaw: it does not correctly handle |