shell behaviour on "Paste Plus" and runfile()

Hello!

I'm using the wx.py.shell.Shell.

When I want to paste multi-line code, I've got problems with the indentation.
E.g. I have a file with the following content:

for n in range(2):
    print n
print "End", n

When I copy & paste this, I get the following, which is obviously not
what I want:

for n in range(2):

... print n
... print "End", n
...

If I want to run the complete file, I can do so with exec on the open file.
But when I want to use the shell's runfile method on the open file, this
fails:

self.shell.runfile(r"J:\test.py")
for n in range(2):

... print n
... print "End", n
  File "<input>", line 3
    print "End", n
        ^
SyntaxError: invalid syntax

For interactive use it might make sense that I have to add an additional
empty line to trigger the execution, but for the described cases, I think
this is not the right behaviour.
I know that I can work around by having an empty line before the last line,
but this is not very nice.

Any hints? Is there a configuration option?

Regards,

Dietmar

Robin Dunn wrote:

Dietmar Schwertberger wrote:

Hello!

I'm using the wx.py.shell.Shell.

When I want to paste multi-line code, I've got problems with the indentation.
E.g. I have a file with the following content:

for n in range(2):
    print n
print "End", n

When I copy & paste this, I get the following, which is obviously not
what I want:

for n in range(2):

... print n
... print "End", n
...

This is what the Paste Special menu item is for.

Oops, I see that this isn't working as expected either unless you provide the >>> and ... prompts in the text that you are pasting. I'll look at patches for this too if you want to try and take it on.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!