[Python-ideas] [Python-Dev] Inclusive Range
fuzzyman at voidspace.org.uk
Tue Oct 5 15:16:20 CEST 2010
On 05/10/2010 14:13, C. Titus Brown wrote:
> On Tue, Oct 05, 2010 at 02:07:41PM +0100, Michael Foord wrote:
>> On 5 October 2010 12:51, Carl M. Johnson<cmjohnson.mailinglist at gmail.com>wrote:
>>> Yup. TANSTAAFL. That's why we shouldn't actually bother to change
>>> things: you lose on the backend what you gain on the frontend. I'm
>>> just curious about whether starting programmers have a strong
>>> preference for one or the other convention or whether both are
>> Both teaching new programmers and programmers coming from other languages
>> I've found them confused by the range behaviour and usually end up having to
>> apologise for it (a sure sign of a language wart).
>> It is *good* that range(5) produces 5 values (0 to 4) but *weird* that
>> range(3, 10) doesn't include the 10.
>> Changing it now would be *very* backwards incompatible of course. Python 4
> Doesn't it make sense that
> len(range(5)) == 5
> for i in range(5):
> mimics the C/C++ behavior of
> for (i = 0; i< 5; i++) ...
Yes. That is why I said that the current behaviour of range for a single
input is *good*. Perhaps I should have been clearer; it is only the
behaviour of range(x, y) that I've found people-new-to-python confused by.
All the best,
READ CAREFULLY. By accepting and reading this email you agree,
on behalf of your employer, to release me from all obligations
and waivers arising from any and all NON-NEGOTIATED agreements,
licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap,
confidentiality, non-disclosure, non-compete and acceptable use
policies (”BOGUS AGREEMENTS”) that I have entered into with your
employer, its partners, licensors, agents and assigns, in
perpetuity, without prejudice to my ongoing rights and privileges.
You further represent that you have the authority to release me
from any BOGUS AGREEMENTS on behalf of your employer.
More information about the Python-ideas