[Python-ideas] Should range() == range(0)?
Alexander Belopolsky
alexander.belopolsky at gmail.com
Mon May 7 19:16:11 CEST 2012
On Mon, May 7, 2012 at 6:50 AM, Georg Brandl <g.brandl at gmx.net> wrote:
>> Having range() return an empty range in the same way that tuple()
>> returns an empty tuple would be a natural extension of that
>> philosophy.
>
> For what gain?
Lack of the default constructor is a pain for generic programming in
Python. It is not uncommon to require an arbitrary instance of the
given type and calling the type without arguments is a convenient way
to get one. I never missed working range() mostly because I don't
recall ever using range as an actual type rather than the Python way
to spell the C for loop. I do, however often miss default
constructors for datetime objects, so I understand why some people may
desire range().
More information about the Python-ideas
mailing list