<nanotech at europa.com> wrote in message news:mailman.988402866.799.python-list at python.org... [snip] > >>> print reduce(lambda x, y: x+y, map(int,fh.xreadlines())) > Traceback (most recent call last): > File "<pyshell#91>", line 1, in ? > print reduce(lambda x, y: x+y, map(int,fh.xreadlines())) > TypeError: argument 2 to map() must be a sequence object > > Ack!! Why will map not fudge? What am I missing?? Is it pilot error?? I think map() needs to know the *length* of its sequence arguments, and the object returned by .xreadlines() doesn't/can't supply it -- it's more of an "undetermined-length sequence" (sensibly-- how would length be determined without reading everything?). Since we don't formally have interfaces/protocols in Python, but rely on informal docs, such ambiguities recur -- it's never really clear when the docs say "a sequence" whether they mean a length is needed or not, just like "a function" may be any callable in many cases but not all, etc. PEP 245/246 might help... Alex
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