[Python-Dev] Anyone know Brendan Scott, author of 'Python for Kids'? (original) (raw)

Terry Reedy tjreedy at udel.edu
Sun Aug 21 17:22:59 EDT 2016


Brendan Scott, author of 'Python for Kids for Dummies' is revising his book to produce a Python 3 version. Great so far.

Unfortunately, he thinks that Python 3 turned range() into a (generator) function that produces a generator, one that can be indexed and sliced. I left a comment on his blog explaining that range() still produces arithmetic sequence objects. The difference is that in Py 3, the compact representation is not expanded to a verbose (and redundant) Python list until requested. It is not like map and filter, which were changed to return iterators.

For whatever reason, my comment had no effect and today on https://python4kids.brendanscott.com/2016/08/21/python-for-kids-python-3-project-7/ he still says, near the top

range(10) is no longer a list. Rather, it's a generator

so the [:] operator slices the generator. You can use list()

to see what list the generator corresponds to.

I left a second comment, again with interactive code examples, but I fear the result (nothing) will be the same. We cannot stop people from publishing such misleading dis-information, but we can discourage it, and I think we should, especially if we can before paper copies are printed. Beginners have enough problem with iterables versus iterators without a major beginner book confusing the two. I imagine this leading to tutor-list and Stackoverflow questions like "Why doesn't slicing my generator work? It did for range?"

So, if you agree with me, please either write Brendan personally if you know him, or just leave your own comment on the blog.

-- Terry Jan Reedy



More information about the Python-Dev mailing list