Michael Smith writes: > This is just a small improvement, but worthwhile. It's intuitive IMO to be > able to use similar filtering expressions to comprehensions at the top of a > for loop.
Intuitive I guess, but in comprehensions it was "strictly from need" since comprehension syntax is an expression. There is no other way to explicitly filter in comprehensions. (One could write a generator function to do the filtering, but "explicit is better ...".) > Here's an example: > > for path in Path("pyspark/jars")).glob("hadoop-*.jar") if not > path.stem.startswith("hadoop-shaded-guava"): "Bad MUA! Bad, bad MUA! You know you're not supposed to respect line length constraints when somebody's trying to make a point." My 63-year-old eyes struggle with 80-character lines, but in all fairness to those with better eyesight I'm not going to argue for Mom's 65[1]. But 106 (and that's assuming this is top-level "scripting" code) would get a "restructure and resubmit" from me. Footnotes: [1] The number of characters produced by my Mom's typewriter with 6.5" lines. _______________________________________________ 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/UEYEC4ZS2AHEMM4O7UXTZLUJEDMAK5QF/ Code of Conduct: http://python.org/psf/codeofconduct/