On Mon, Oct 17, 2016 at 7:50 PM, Random832 <random...@fastmail.com> wrote:
> On Mon, Oct 17, 2016, at 22:17, David Mertz wrote: > > > [*range(x) for x in range(4)] > > > > As Paul or someone pointed out, that's a fairly odd thing to do. > > I agree with the specific example of it being an odd thing to do with > range, it was just an attempt to illustrate with a concrete example. > It's also easy to construct examples where the hypothetical * syntax can't handle a requirement. E.g. flatten() with levels>1 (yes, of course you can find some way to nest more loops or more comprehensions-within-comprehensions to make it work in some way that still uses the * by force). I feel like I should be honest about something else - I'm always a > little bit confused by the ordering for comprehensions involving > multiple clauses. Me too! I get the order of nested loops in comprehensions wrong about 25% of the time. Then it's a NameError, and I fix it. This is a lot of why I like a utility function like `flatten()` that is pretty much self-documenting. Perhaps a couple other itertools helpers would be nice. -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.
_______________________________________________ Python-ideas mailing list Pythonemail@example.com https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/