> Personally, I'm certainly not ignoring comprehensions. "for thing in > (x for x in collection if is_interesting(x))" uses comprehensions just > fine, if you don't like the verbosity of "x for x in", then that's an > issue with comprehensions, not a reason why comprehensions don't > address this issue, surely? (Personally, I find the repetitiveness of > "x for x in" mildly annoying, but not enough to put me off > comprehensions[1]).
Earlier on the thread, I made a similar point that it would be nice to have a way to filter without the redundant for x in x. Though I can’t think of a really good way to express it. But as for filtered for loops: "for thing in (x for x in collection if is_interesting(x))" It not so much the extraneous “x for x” as the duplicated “for thing in” that bugs me. I’m curious— to the skeptics: do you think that The above (or a later if block) is just as good or better than for thing in collection if isinteresting(thing): Or just that it’s not worth it to make a change. But the other part of why I think comprehensions are relevant is that introducing anf if to the for statement is not brand new syntax - it would be allowing existing syntax in a new context that is highly related. And as for documentation and all that, it’s hard to imagine very many people not understanding what it means. Do I care enough to write a PEP? No. So this, like many other small ideas, will probably die on the vine. Oh well. -CHB -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3DRA3FCHGONGQFFIDQSXGCG3IXQ6I2CI/ Code of Conduct: http://python.org/psf/codeofconduct/