What sort of console info are you trying to get? Can you show a really
simple example, a “Hello world” example that doesn’t require networking
Also, while you are still writing your code, you should never, ever
write bare except clauses like this:
# code here
# Don't do this!
print("Unable to get Hostname and IP")
Why can’t you get the hostname and IP address? How can I fix it? Who
Well, the computer did know, but then you, the programmer, came along
and threw away all the information that would let you debug the
problem, and replaced it with an error message that is almost as useless
as the cursed “An error occurred”. Great. What sort of error? How can I
That sort of error message is not user-friendly, it is user-hostile.
And when you are debugging your own code, it is like trying to fix a
fault while wearing a blindfold.
As a programmer, a traceback showing which line of code failed, and why
it failed, is your best friend in the world. Bare except clauses are
almost always one of the worst things you can do in your code:
So help yourself: take out the try…except until you can see exactly
what sort of errors you get. Fix the ones which are bugs in your code.
(If any.) The ones which are temporary errors, like socket timeouts, you
might want to retry the operation. And then, only when you know what
precise unrecoverable errors can occur, should you catch them and then
decide whether to hide the information from your users:
“You want the truth? YOU CAN’T HANDLE THE TRUTH!!!”
or give them enough information to fix the problem themselves.