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?

Coding is not hard. No, not at all.
What is hard is making code that accepts different and sometimes unexpected types of input and still works.
This is what truly takes a large amount of effort on a developer's part.

Thumbs up

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

if you wish,  you could give a look at my github profile.
If you want to get in touch with me you can follow me on Twitter
have a nice day.
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.

Ironcross is here to expose the fakes and phonies,
Suss out the wheat from the chaff, the cheddar from the bologna,
I'm a superhero, y'all fools needa know this,
So if you on the other side of right, prepare for a fight no one will ever miss.

Thumbs up

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

Thumbs up

2019-05-09 20:49:15

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

Coding is not hard. No, not at all.
What is hard is making code that accepts different and sometimes unexpected types of input and still works.
This is what truly takes a large amount of effort on a developer's part.

Thumbs up

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.

My tactical battle scripts: https://www.dropbox.com/s/dzsmqv2pgqvu1 … h.zip?dl=1
Currently, one of my favorite games is Trimps.
So I'm the Trimper Trooper!

Thumbs up

2019-05-09 21:41:24

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

if you wish,  you could give a look at my github profile.
If you want to get in touch with me you can follow me on Twitter
have a nice day.
Paul