This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zach.ware
Recipients BTaskaya, rhettinger, zach.ware
Date 2020-05-08.21:13:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588972401.0.0.940156523513.issue40568@roundup.psfhosted.org>
In-reply-to
Content
This can be accomplished already by just including newlines in the string:

$ cat multiline_python_bash_script.sh 
#!/bin/bash

python3 -c '
from math import *
print(e**(1j * pi))
import sys
print(sys.argv)'

echo "here's some random text" > somefile.txt

python3 -c '
with open("somefile.txt") as f:
    print(len(f.read()))

import sys
print(sys.argv)'


python3 - << EOF
import sys

print("Here's another way to do it, without restrictions on quotes")
print(sys.argv)
EOF
$ ./multiline_python_bash_script.sh 
(-1+1.2246467991473532e-16j)
['-c']
24
['-c']
Here's another way to do it, without restrictions on quotes
['-']
$ python3 -c "
> print('Interactive test:')
> print('Multi-line works')
> "
Interactive test:
Multi-line works



None of these options is particularly *pretty*, but if it's at the point the ugliness bothers you it should probably be its own file to be executed :).  On the other hand, none of these options really works on Windows, as far as I know.
History
Date User Action Args
2020-05-08 21:13:21zach.waresetrecipients: + zach.ware, rhettinger, BTaskaya
2020-05-08 21:13:21zach.waresetmessageid: <1588972401.0.0.940156523513.issue40568@roundup.psfhosted.org>
2020-05-08 21:13:20zach.warelinkissue40568 messages
2020-05-08 21:13:20zach.warecreate