Problem with stdin in python script (macOS)


127
views
1
7 weeks ago by
Hi,

I have problem with this script in WingIDE:
http://introcs.cs.princeton.edu/python/15inout/plotfilter.py

I use this file:
http://introcs.cs.princeton.edu/python/15inout/usa.txt
 as "Run arguments" in "Launch configurations" (< usa.txt).

Libraries:
http://introcs.cs.princeton.edu/python/code/stdio.py
http://introcs.cs.princeton.edu/python/code/stddraw.py

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

Thanks!
Community: Wing Python IDE

1 Answer


3
7 weeks 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 http://wingware.com/doc/debug/debugging-externally-launched-code 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 = f.read()
f.close()
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: 127.0.0.1 [0 modules loaded]
General: Document Open Failed::Failed to open document '/Applications/WingIDE.app/Contents/Resources/bin/dbg/src/wingbase/channel.py'"

There is no such a file in this directory.

written 7 weeks 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 wingdbstub.py 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 18 days ago by Wingware Support  
1
Well, I've just copy this file from Wing (win edition). It's OK now. Thanks for support!
written 18 days ago by andrewd76  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »