2019-05-08 20:44:14

So my friend is coding in python, and we're having the weirdest issues. He opens up cmd, goes into his directory with the script, runs it, and is unable to see the traceback. The only time that traceback is seen if it occurs while the python is processing the file, that is, a runtime error.
Yes, he is in the object review mode, yes, he's using nvda+up and down arrows to try and read the screen, but it still doesn't work. He's on windows 10, by the way.
So, tips? Is there a way to catch and write a traceback to a log or something? I'm aware of try and except statements, but surely you don't need to wrap the program in a giant web of try and except to catch any problems that may arise?

2019-05-08 21:20:58

you could try forwarding your traceback to the clipboard or to a file
1. If you want to get the output in your clipboard you can type
python script.py 2>&1 | clip
2. If instead you wish to review the error in a file you could do this
python script.py > error.txt 2>&1

Paul

2019-05-09 04:00:34

does redirecting stdout and stderr into one stream like that work on windows? I kind of doubt it, but then again I've not actually tried, as it tends to be a unix / linux thing.

Facts with Tom MacDonald, Adam Calhoun, and Dax
End racism
End division
Become united

2019-05-09 04:58:01

It works, well I don't know about the clipboard, but the second line works. Optionally you could do something like:

python yourscript.py >> output.txt
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2019-05-09 20:49:15

So if I'm writing to a file, where would the file be stored?

2019-05-09 21:03:07

In the CWD.
In the command prompt, type cd to know where that is.
In Python, call os.getcwd() to find that out.

2019-05-09 21:41:24

yes, redirecting stdout and stderr to the clipboard works on windows, at least, on my end

Paul