for loop in one line (for python -c) I want to use python -c to remove wheel files from the dist/ directory in my project. (*)
Actually, I use the following command:
python -c &quot;from pathlib import Path; [p.unlink() for p in Path('dist').glob('Pascal_Scraper-*.whl')]&quot;

Is there a shorter/cleaner way to do that?

(*) the setuptools command python setup.py rotate --keep=1 --match=.whl doesn't work for me.
If you need to use python for being crossplattform and if you need to do this in one line then this is the way to go, yes.
For some reason
Alternatives to consider:

put the code in a file so you can make it more readable
create a Makefile and run this under a target (like clean:)
use os instead of pathlib to see if you like that better (pathlib is fine, though)
use map and a lambda instead of list comprehension, to see if you like that better (probably not though)

I would have expected that a one-line for loop would work, but it doesn't seem to in python -c when there is a command before it.
I think there is no much cleaner solution