Problem with stdin in python script (macOS)

11 months ago by

I have problem with this script in WingIDE:

I use this file:
 as "Run arguments" in "Launch configurations" (< usa.txt).


I run this file, but nothing happens.
If I run this file in Geany - it works.
It works in Terminal too (python < usa.txt)
Is it my mistake or bug in WingIDE?

Community: Wing Python IDE

1 Answer

11 months ago by
Wing does not interpret the < operator like the bash command line so it's not going to send the contents of usa.txt to the code when you set the arguments to this.  The only work-arounds I can think of are either to use wingdbstub to initiate debug so you can type a command line with < outside of Wing (see for details) or modify your code to start by reading the file and redirect stdio.  It would be something like this untested code:

import sys
from StringIO import StringIO  # In Python 3 it's from io import StringIO instead
f = open('usa.txt')
txt =
sys.stdin = StringIO(txt)

Thank you for support! I've initiate debug outside of Wing and received an error: 

"Debugger: Debug process paused; pid=1930; Listening on TCP/IP port 50005
Allowed hosts: [0 modules loaded]
General: Document Open Failed::Failed to open document '/Applications/'"

There is no such a file in this directory.

written 11 months ago by andrewd76  
Sorry, appears we did not get notice of this comment as we usually do.  I'd need more information to diagnose this.  It's trying to stop on an exception in the debugger internals, but I am not sure why.  It should never do that.  You can get a log from the debug side by setting kLogFile in and then we can interpret that if you email it to us.  Although I realize you may have moved on to other things by now, since this reply is 5 weeks late.  We'll look into what is happening to the email notices from this forum (they mostly work, but I'm finding some missed items).
written 10 months ago by Wingware Support  
Well, I've just copy this file from Wing (win edition). It's OK now. Thanks for support!
written 10 months ago by andrewd76  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »