Null object pattern (was: Python 3.0 - is this true?)

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Nov 11 18:17:05 EST 2008


Terry Reedy <tjreedy at udel.edu> writes:

> We're not going to add the "feature" back that None compares smaller
> than everything. It's a slippery slope that ends with all operations
> involving None returning None -- I've seen a proposal made in all
> earnestness requesting that None+42 == None, None() == None, and so
> on. This Nonesense was wisely rejected

I agree with that decision. However, the behaviour you specify *is*
useful (though I don't think ‘None’ should have that behaviour). It is
the “Null object” design pattern, and may be familiar to many
readers in its SQL implementation as the ‘NULL’ non-value.

In fact, there is a Python Cookbook recipe implementing a ‘Null’
object <URL:http://code.activestate.com/recipes/68205/> that also
features in the O'Reilly _Python Cookbook, second edition_.

-- 
 \     “This world in arms is not spending money alone. It is spending |
  `\      the sweat of its laborers, the genius of its scientists, the |
_o__)           hopes of its children.” —Dwight Eisenhower, 1953-04-16 |
Ben Finney



More information about the Python-list mailing list