In article <16272.6895.233187.510629 at montanaro.dyndns.org>, Skip Montanaro <skip at pobox.com> wrote: > I'm not in a mood to try and explain anything in more precise terms this > morning (for other reasons, it's been a piss poor day so far) and must trust > your ability to infer my meaning. I have no idea at this point how to > interpret > > foo[x*x for x in bar] > > That looks like a syntax error to me. You have a probably identifier > followed by a list comprehension. foo[ anything ] does not look like an identifier followed by a list, it looks like an indexing operation. So I would interpret foo[x*x for x in bar] to equal foo.__getitem__(i) where i is an iterator of x*x for x in bar. In particular if iter.__getitem__ works appropriately, then iter[x*x for x in bar] could be a generator comprehension and iter[1:n] could be an xrange. Similarly sum and max could be given appropriate __getitem__ methods. -- David Eppstein http://www.ics.uci.edu/~eppstein/ Univ. of California, Irvine, School of Information & Computer Science
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