Python Forum
How to paste several lines of codes to the Python console - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: How to paste several lines of codes to the Python console (/thread-31517.html)

Pages: 1 2


RE: How to paste several lines of codes to the Python console - cwazuidema - Jan-12-2021

I've got the same problem as well.
I had to reinstall my MacBook and installed python via brew.

Here is a video for people that want to see the problem:
https://youtu.be/CrTzBpVdcVM

Any help is highly appreciated, since I'm stuck for 3 days


RE: How to paste several lines of codes to the Python console - DeaD_EyE - Jan-12-2021

You can use %cpaste in IPython: https://youtu.be/9KDbnWm9l1s


RE: How to paste several lines of codes to the Python console - cwazuidema - Jan-12-2021

I found the solution!!!!

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


RE: How to paste several lines of codes to the Python console - snippsat - Jan-12-2021

IPython as mention or ptpython(as i used for many years now).
Can paste in almost all code into ptpython and it works,and can continue to test.
For Windows in make much better in use cmder in combo with ptpython.
ptpython can also go in change code that has been paste and look at run code that has been paste in before(F3).
class Game:
    def __init__ (self, title, year, price):
        self.title = title
        self.year = year
        self.price = price

    def __str__(self):
        return f'{self.title}, {self.year}, {self.price}'

    def __repr__(self):
        return f'Game({self.title}, {self.year}, {self.price})'

g1 = Game("FIFA", 2008, "€50")
print(g1)
[Image: aev8Z7.png]

Also remember the -i command this work for all interactive shell.
python --help
.....
-i     : inspect interactively after running script; forces a prompt even
         if stdin does not appear to be a terminal; also PYTHONINSPECT=x
[Image: p0ILWq.png]