A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-April/014482.html below:

[Python-Dev] Iterators, map, xreadlines and docs

[Python-Dev] Iterators, map, xreadlines and docsTim Peters tim.one@home.com
Sat, 28 Apr 2001 03:24:48 -0400
A confused user on c.l.py reported that while

    for x in file.xreadlines():

works fine,

    map(whatever, file.xreadlines())

blows up with

    TypeError: argument 2 to map() must be a sequence object

The docs say both contexts require "a sequence", so this is baffling to them.

It's apparently because map() internally insists that the sq_length slot be
non-null (but it's null in the xreadlines object), despite that map() doesn't
use it for anything other than *guessing* a result size (it keeps going until
IndexError is raised regardless of what len() returns, growing or shrinking
the preallocated result list as needed).

I think that's a bug in map().  Anyone disagree?

If so, fine, map() has to be changed to work with iterators anyway <wink>.

How are we going to identify all the places that need to become
iterator-aware, get all the code changed, and update the docs to match?  In
effect, a bunch of docs for arguments need to say, in some words or other,
that the args must implement the iterator interface or protocol.  I think
it's essential that we define the latter only once.  But the docs don't
really define any interfaces/protocols now, so it's unclear where to put
that.

Fred, Pronounce.  Better sooner than later, else I bet a bunch of code
changes will get checked in without appropriate doc changes, and the 2.2 docs
won't match the code.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4