[Python-Dev] python 3 niggle: None < 1 raises TypeError

Isaac Morland ijmorlan at uwaterloo.ca
Fri Feb 14 22:42:44 CET 2014


On Fri, 14 Feb 2014, Chris Barker wrote:

> This is actually a pretty common case -- the question here is: Is this
> really None? or does None have a special meaning. It sounds like this is a
> wrapper for a PostgreSQL range object, in which case None isn't really
> right, there must be a +-infinity concept there -- how does postgress handle
> it? (is this a generic range, or a datetime range? I'm not up on it).
> If this means what I think it does, None is really a hack, both because of
> al lteh specia case code required for sorting, comparing, etc, but also
> because it's missing information -- the two ends of the range should really
> have different meanings.

Postgres range types are a separate kind of type which can be created 
using CREATE TYPE:

http://www.postgresql.org/docs/current/interactive/sql-createtype.html

Several handy range types are built in, although not as many as one might 
expect.

Postgres ranges can be made infinite by specifying NULL as a bound. 
There isn't a separate special value for this.  This has somewhat strange 
effects when the base type of the range has its own "infinity" value:

=> select upper_inf (daterange (current_date, 'infinity'));
  upper_inf
-----------
  f
(1 row)

=> select isfinite ('infinity'::date);
  isfinite
----------
  f
(1 row)

=> select upper_inf (daterange (current_date, null));
  upper_inf
-----------
  t
(1 row)

In other words, a range with non-NULL bounds is finite according to the 
range functions even if the bound is the infinity value of the base type.

Isaac Morland			CSCF Web Guru
DC 2619, x36650			WWW Software Specialist


More information about the Python-Dev mailing list