On Tue, Jan 5, 2021, at 17:17, lasizoillo 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
what if we had special support for python -c (and maybe in some other places like exec(), but definitely not for source files) for the purpose of one-liners? Then the syntax wouldn't need to be suitable for general purpose use, and you could do something like "have ~{ ~} ~; as alternate spellings of INDENT, DEDENT, and NEWLINE respectively" python -c 'import os~;for key, value in os.environ.items():~{if key.startswith("XDG"):~{print(f"{key}:{value}")~}~}' _______________________________________________ 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/QBUKHJBOXYTYO4TMWUJQZ5RNYDCVXLY5/ Code of Conduct: http://python.org/psf/codeofconduct/