> You might be able to avoid calling the method twice using the walrus operator.
I specifically discussed the walrus operator solution, but both you and Dominik Vilsmeier seem to have missed that. > I'd use the list constructor with a > named function anyway, rather than inlining it in a comprehension. I > consider that more readable. I'm curious, how do you find this: def clean(): for line in lines: line = line.strip() if line: yield line clean_lines = list(clean()) more readable than this? clean_lines = [ for line in lines: line = line.strip() if line: yield line ] It's not that I find my version particularly readable, but I don't see how it's worse. _______________________________________________ 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/UNMZTO7QGYD53SUWSFMGZEVUPEIOSAVF/ Code of Conduct: http://python.org/psf/codeofconduct/