[Python-ideas] Should range() == range(0)?

Greg Ewing greg.ewing at canterbury.ac.nz
Mon May 7 07:05:30 CEST 2012


Steven D'Aprano wrote:

> The cases of int, float, complex etc. are a little more dubious; I'm not 
> convinced there's a general philosophical reason why int() should be 
> allowed at all.

A philosophical reason would be that list() and int()
both return false values. Pragmatically, it makes them useful
as arguments to defaultdict.

The fact that there is sometimes more than one representation
of zero isn't much of a problem, since they all give the same
result when you add a nonzero value to them.

The defaultdict argument doesn't apply to range() in Python 3, or
xrange() in Python 2, since you can't apply += to them. It
also doesn't apply much to range() in Python 2, since list
would work just as well as a defaultdict argument as a range
that accepted no arguments.

-- 
Greg



More information about the Python-ideas mailing list