Pasting interpreter prompts

One gripe that i hear a lot is that it's really difficult to cut and paste chunks of Python code when you're working with the interpreter because the ">>> " and "... " prompts keep getting in the way. Does anyone else often have or hear of this problem? Here is a suggested solution: for interactive mode only, the console maintains a flag "dropdots", initially false. After line = raw_input(">>> "): if line[:4] in [">>> ", "... "]: dropdots = 1 line = line[4:] else: dropdots = 0 interpret(line) After line = raw_input("... "): if dropdots and line[:4] == "... ": line = line[4:] interpret(line) The above solution depends on the fact that ">>> " and "... " are always invalid at the beginning of a bit of Python. So, if sys.ps1 is not ">>> " or sys.ps2 is not "... ", all dropdots behaviour is disabled. I realize it's not going to handle all cases (in particular mixing pasted text with typed-in text), but at least it makes it *possible* to paste code, and it's quite a simple rule. I suppose it all depends on whether or not you guys often experience this particular little irritation. Any thoughts on this? -- ?!ng

Ping> One gripe that i hear a lot is that it's really difficult to cut Ping> and paste chunks of Python code when you're working with the Ping> interpreter because the ">>> " and "... " prompts keep getting in Ping> the way. Does anyone else often have or hear of this problem? First time I encountered this and complained about it Guido responded with import sys sys.ps1 = sys.ps2 = "" Crude, but effective... -- Skip Montanaro | http://www.mojam.com/ skip@mojam.com | http://www.musi-cal.com/

On Mon, 17 Apr 2000, Skip Montanaro wrote:
First time I encountered this and complained about it Guido responded with
import sys sys.ps1 = sys.ps2 = ""
Crude, but effective...
Yeah, i tried that, but it's suboptimal (no feedback), not the default behaviour, and certainly non-obvious to the beginner. -- ?!ng

On Mon, 17 Apr 2000, Ka-Ping Yee wrote:
One gripe that i hear a lot is that it's really difficult to cut and paste chunks of Python code when you're working with the interpreter because the ">>> " and "... " prompts keep getting in the way. Does anyone else often have or hear of this problem?
Here is a suggested solution: for interactive mode only, the console maintains a flag "dropdots", initially false.
After line = raw_input(">>> "): if line[:4] in [">>> ", "... "]: dropdots = 1 line = line[4:] else: dropdots = 0 interpret(line)
Python 1.5.2 (#1, Feb 21 2000, 14:52:33) [GCC 2.95.2 19991024 (release)] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
a=[] a[ ... ... ... ] Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: sequence index must be integer
Sorry. -- Moshe Zadka <mzadka@geocities.com>. http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com

On Tue, 18 Apr 2000, Ka-Ping Yee wrote:
On Tue, 18 Apr 2000, Moshe Zadka wrote:
a=[] a[ ... ... ... ] Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: sequence index must be integer
Sorry.
What was your point?
That "... " in the beginning of the line is not a syntax error. -- Moshe Zadka <mzadka@geocities.com>. http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com

On Tue, 18 Apr 2000, Moshe Zadka wrote:
What was your point?
That "... " in the beginning of the line is not a syntax error.
So? You can put "... " at the beginning of a line in a string, too: >>> a = """ ... ... spam spam""" >>> a '\012... spam spam' That isn't a problem with the suggested mechanism, since dropdots only comes into effect when the *first* line entered at a >>> begins with ">>> " or "... ". -- ?!ng "Je n'aime pas les stupides gar�ons, m�me quand ils sont intelligents." -- Roople Unia

Has anybody noticed that this is NOT a problem in IDLE? It will eventually go away, especially for the vast masses. So I don't think a solution is necessary -- and as was shown, the simple hacks don't really work. --Guido van Rossum (home page: http://www.python.org/~guido/)

On Tue, 18 Apr 2000, Guido van Rossum wrote:
Has anybody noticed that this is NOT a problem in IDLE?
Certainly. This was one of the first problems i solved when writing my console script, too. (Speaking of that, i still can't find auto-completion in IDLE -- is it in there?) But: startup time, startup time. I'm not going to wait to start IDLE every time i want to ask Python a quick question. Hey, i just tried it and actually it doesn't work. I mean, yes, sys.ps2 is missing, but that still doesn't mean you can select a whole line and paste it. You have to aim very carefully to start dragging from the fourth column.
So I don't think a solution is necessary -- and as was shown, the simple hacks don't really work.
I don't think this was shown at all. -- ?!ng
participants (5)
-
Fredrik Lundh
-
Guido van Rossum
-
Ka-Ping Yee
-
Moshe Zadka
-
Skip Montanaro