node6.html/ comments/457u
last updated 2 years ago by effbot #
(effbot: fixed markup to work around infogami HTML generation bug)
Here are my current suggestions for updates to this page, I'd like some feedback:
In the range() section the example for the following is (Pythonically) incorrect: "To iterate over the indices of a sequence, combine range() and len() as follows:" It should really be using enumerate(). range(len(x)) is only useful if you don't want to access elements of x, but just want the indices. Besides enumerate() is already described in the previous chapter under "Looping Techniques". I think this entire paragraph (i.e. last para of "The range() function" section) should be removed.
In "The range() function", should we add somethign about xrange()? I was thinking it is useful to introduce the concept of a generator, efficiently producing objects as you need them. However, I discovered xrange() returns an object of type [type 'xrange'] which is different from the [type 'generator'] created by a function containing yield. I would not want to add incorrect info.
The flow of matter regarding **kw and *args is not clear to me. I suggest creating a new section "Catch-all arguments" after "Keyword Arguments". The following will be removed: "Arbitrary Argument Lists" and last few paras of "Keyword Arguments" (starting at "When a final...").
Alternatively, just remove the last few paras of "Keyword Arguments" (starting with "When a final..."). That improves the text quite a bit, but does not include the **kw syntax.

I think it'd be better to keep what's there, and then after show the Pythonic way of doing it. It's nice to remind people that you can in fact index lists, if you want, but usually you don't have to
Well, xrange() is funny because it's one of those rare iterators that don't just return
selfwhen__iter__() is called. I think getting into the details of that would be too much now, but I do think it's worth it to mention xrange() here.Baseline 2 years ago #