[Python] How to execute multiline python code from a bash script?

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    I need to extend a shell script (bash). As I am much more familiar with python I want to do this by writing some lines of python code which depends on variables from the shell script. Adding an extra python file is not an option.

    result=`python -c "import stuff; print('all $code in one very long line')"`


    is not very readable.

    I would prefer to specify my python code as a multiline string and then execute it.

    Continue reading...

Compartilhe esta Página