Do you think that throwaway list comprehensions as shorthand for loops is good/ok style?
from wasabi@feddit.de to python@programming.dev on 12 Oct 2023 11:06
https://feddit.de/post/4446754
from wasabi@feddit.de to python@programming.dev on 12 Oct 2023 11:06
https://feddit.de/post/4446754
I’m talking about stuff like this: [file.unlink() for file in files]
instead of the more verbose but maybe easier to grasp for python noobs:
for file in files: file.unlink()
Maybe with a bit more context:
def _cleanup(self) -> None: dirs, files = partition(lambda f: f.is_file(), self._tmp_dir.rglob("*")) [file.unlink() for file in files] [dir.rmdir() for dir in dirs] self._tmp_dir.rmdir()
#python
threaded - newest