Python Forum
How to paste several lines of codes to the Python console
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to paste several lines of codes to the Python console
#11
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
22_alias likes this post
Reply
#12
You can use %cpaste in IPython: https://youtu.be/9KDbnWm9l1s
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#13
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
22_alias and DeaD_EyE like this post
Reply
#14
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]
22_alias likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with Spyder IDE: Clear console doesn't actually clear the console GalacticStarfish 2 5,587 Sep-03-2017, 09:01 PM
Last Post: dvs1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020