El mar, 5 ene 2021 a las 0:35, Paul Sokolovsky (<pmiscml@gmail.com>) escribió:

On Tue, 5 Jan 2021 08:52:54 +1100
Steven D'Aprano <steve@pearwood.info> wrote:

>> We love Python. We love them bash one-liners. We want to do
>> one-liners in Python.

The most vivid real-world example of that I know is Frida the
reverse-engineering framework (https://frida.re). The issue is so
prominent that they admit it on the first page of the docs

>> Why a Python API, but JavaScript debugging logic?

What they write under that title is now marketing blah-blahing, but I
remember when it leaked the sad truth: "We use JavaScript because its
syntax more suitable for one-liners and small code snippets". If there
was a generally accepted alternative syntax for Python, situation might
have been different.

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
import os
for key, value in os.environ.items():
    if key.startswith("XDG"):

and although it can be embedded in a shell script or written in command line it has more than one line.

Really is better add braces to python that write some docs explaining how to use it in command line? What are the issues with multi-line command line executions?

Maybe I have missed some point. But this is the best reason I've read and I don't understand why is useful.



PD: Python not only can be used in console, Python can be the console https://ipython.org/ipython-doc/stable/interactive/shell.html