Stripping ps1/ps2 when pasting into IDLE.

Lloyd Zusman ljz at asfast.com
Fri May 28 00:44:41 EDT 1999


"Mark Hammond" <MHammond at skippinet.com.au> writes:

> Sure - why not write a "SmartPaste" IDLE extension, and change the default
> bindings for paste to your extension.  Then once it works OK, post it here,
> and if people find it useful (I would) Im sure it would be adopted.  Writing
> a new IDLE extension is vaguely documented, but with the existing samples it
> is quite trivial...

Well, this could work, but it wouldn't be general enough for my needs.
When I cut or copy from outside of IDLE and try to paste into IDLE, no
IDLE code is executed to do this pasting.  The text just looks like
it's being typed in from the keyboard.  The only time an IDLE
extension could be used for my customized pasting would be in the case
where the original cutting or copying is done from within IDLE using
its facilities.

I'm thinking of another approach: putting code into the `runit' method
of PyShell to strip off leading ps1/ps2 strings from all input lines
before passing these lines on to `self.interp.runsource'.  This would
work no matter where the text was pasted from, and even if the text
was typed by hand (although I can't decide if that's an advantage or a
disadvantage).

At any rate, it seems like this would be a fairly straightforward
thing to do, and I'm wondering if anyone who is more familiar with
IDLE can see any potential pitfalls to this approach.



-- 
 Lloyd Zusman
 ljz at asfast.com




More information about the Python-list mailing list