On Wed, Jan 6, 2021 at 9:17 AM lasizoillo <lasizoi...@gmail.com> wrote: > > Sorry, but if I'm understanting the point is to make one-liners. For example, > if I want to do something like: > > $ env | grep "^XDG" > > In one python one liner like > > $ python -c 'import os;print("\n".join([f"{key}:{value}" for key, value in > os.environ.items() if key.startswith("XDG > ")]))' > > I can, but If I have things that require indentation I must change it to > something like: > > $ python << EOF
I don't know about inferior shells, but with Bourne-compatible shells (tested in bash and dash, but probably pretty much anything), you can simply open a quote and proceed to create a multi-line command. $ python3 -c 'for n in range(1, 10): > if n % 3: > print("Not a multiple of three:", n) > ' Not a multiple of three: 1 Not a multiple of three: 2 Not a multiple of three: 4 Not a multiple of three: 5 Not a multiple of three: 7 Not a multiple of three: 8 $ ChrisA _______________________________________________ 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/XKVO5LZRJEZRGKZTDOJOMOEVPTS5MSV6/ Code of Conduct: http://python.org/psf/codeofconduct/