1

When I paste several lines at once in a Python3.9 session in the terminal in my Mac it does not understand that they are different lines, and it fails:

Python 3.9.1 (default, Jan  8 2021, 17:17:17) 
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 7
b = 3
a + b
  File "<stdin>", line 1
    a = 7
b = 3
a + b

         ^
SyntaxError: multiple statements found while compiling a single statement

But the funny thing is that if I do it in a Python2.7 it goes well:

Python 2.7.16 (default, Jun  5 2020, 22:59:21) 
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 7
>>> b = 3
>>> a + b
10

I would think that there is something in my environment or bash_profile but why it fails only in the 3.9 version?

Thanks in advance. Miguel.

1 Answer 1

0

I know that it might sound totally unrelated but I've recently had a similar issue. Thing is, I'm on Linux and can't check on Mac. Bash defaults changed in 5.1, that was the root cause. In my case the text was also pasted 'highlighted' when I pasted it in regular shell, and it turned out that setting enable-bracketed-paste off helped - not only with the highlited thing but also with the python3 shell paste, which was broken for some time as well.

So, I'd recommend having a look into some input defaults / settings, on Linux distros that can be configured in the .inputrc file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .