[Python-Dev] range objects in 3.x (original) (raw)
Stephen J. Turnbull turnbull at sk.tsukuba.ac.jp
Wed Sep 28 04:11:51 CEST 2011
- Previous message: [Python-Dev] range objects in 3.x
- Next message: [Python-Dev] range objects in 3.x
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Ethan Furman writes:
Well, actually, I'd be using it with dates. ;)
Why are you representing dates with floats?
(That's a rhetorical question, don't answer it.)
This is the whole problem with this discussion. Guido is saying (and I think it's plausible though I don't have enough experience to be sure myself) that if you look at the various use cases for such functions, they're different enough that it's going to be hard to come up with a single API that is good, let alone optimal, for them all. Then people keep coming back with "but look at X, where this API is clearly very useful", for values of X restricted to "stuff they do".
That's good module design; it's not a good idea for the language (including builtins). Remember, something like range (Python 3) or range (Python 2) was really necessary[1] to express in Python the same algorithm that the C construct 'for' does. I agree with Steven d' that count would have been a somewhat better name (at least in my dialect it is possible, though somewhat unusual, to say "count up from 10 to 20 by 3s"), but that doesn't become clear until you want to talk about polymorphic versions of the concept. Also, in statistics "range" refers to a much smaller set (ie, {min, max}) than it does in Python, not that I really care.
As far as a name for a more general concept, perhaps "interval" would be an interesting choice (although in analysis it has a connotation of continuity that would be inappropriate for a discrete set of floats).
Footnotes: [1] FSVO "necessary" that includes "let's not do arithmetic on the index variable inside the loop".
- Previous message: [Python-Dev] range objects in 3.x
- Next message: [Python-Dev] range objects in 3.x
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]