Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install extremes

How to install Extremes

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install extremes
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.1.1 Available View build log
Windows (64-bit)
1.1.1 Available View build log
Mac OS X (10.5+)
1.1.1 Available View build log
Linux (32-bit)
1.1.1 Available View build log
Linux (64-bit)
1.1.1 Available View build log
Lastest release
version 1.1.1 on Jan 5th, 2011

The peak.util.extremes module provides a production-quality implementation of the Min and Max objects from PEP 326. While PEP 326 was rejected for inclusion in the language or standard library, the objects described in it are useful in a variety of applications. In PEAK, they have been used to implement generic functions (in RuleDispatch and PEAK-Rules), as well as to handle scheduling and time operations in the Trellis. Because this has led to each project copying the same code, we've now split the module out so it can be used independently.

Some simple usage examples:

>>> from peak.util.extremes import Min, Max
>>> import sys
>>> Min < -sys.maxint
>>> Min < None
>>> Min < ''
>>> Max > sys.maxint
>>> Max > 99999999999999999
>>> type(Min)
<class 'peak.util.extremes.Extreme'>

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 instances of the Extreme type.

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 comparisons with classic class instances. Therefore, this version defines methods for all six rich comparison operators, to ensure correct support for classic as well as new-style classes:

>>> Max >= Min and Max > Min and Max==Max and Max!=Min

System Message: ERROR/3 (<string>, line 44)

Inconsistent literal block quoting.

True >>> Max < Min or Max <= Min or Max==Min or Max!=Max False

>>> Min <= Max and Min < Max and Min==Min and Min!=Max
>>> Min > Max or Min >= Max or Min==Max or Min!=Min
>>> class X:
...     """Ensure rich comparisons work correctly with classic classes"""
>>> x = X()
>>> Min<x<Max and Min<=x<=Max and Min!=x!=Max and Max!=x!=Min
>>> Min>x or x>Max or x<=Min or x>=Max or x==Min or Min==x

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.