I'm having trouble copy-pasting code in Python. Say I have the following code I want to paste into a Python interpreter:
string_one = "Help"
string_two = "Me"
Locally, running 3.8.5 on a Mac OSX 10.15.7, if I paste that code, I get SyntaxError: multiple statements found while compiling a single statement
.
However, if I ssh into another machine, open up Python (3.7.4), and paste those two lines, I get no error. Also, when I paste those two lines into a Python 2.7.16 shell, I get no error. What could possibly be the problem here?
Python 3 (problem shell)
Python 2 (non-problem shell)
IdleX provides the PastePyShell.py extension for IDLE which allows pasting of multiple lines into the shell for execution.
The shortcut to comment multiple lines in Python and PyCharm are: Windows or Linux: Ctrl + / Mac OS: Command + /
To copy text, just select it and hit Ctrl-C (Command-C on a Mac). If the highlight marking the selection disappears, that's normal and it means it's worked. To paste, use Ctrl-V (Command-V on a Mac).
It seems that there is a bug in readline (which is used by Homebrew to install python)
Short answer:
echo "set enable-bracketed-paste off" >> ~/.inputrc
Long answer: https://github.com/Homebrew/homebrew-core/issues/68193
(This was erroneously edited into the question; I have rolled back that edit, and am pasting the solution as an actual answer instead, and tagging as Community Wiki.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With