On Tue, Jan 19, 2021 at 8:58 AM Random832 <[email protected]> wrote:
>
> 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}")~}~}'
>

What if we had shells that actually allow you to put newlines inside quotes?

$ python3 -c 'import os
> for key, value in os.environ.items():
>   if key.startswith("XDG"): print(f"{key}:{value}")
> '

ChrisA
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/YBKWDSKKT2J3FZGJFLY5ZIWGIWIBH735/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to