Top "Try-except" questions

A form of error handling in Python and Delphi, similar to try/catch in C-like languages.

Try-except clause with an empty except code

Sometimes you don't want to place any code in the except part because you just want to be assured of …

python try-except
python exit infinite while loop with KeyboardInterrupt exception

My while loop does not exit when Ctrl+C is pressed. It seemingly ignores my KeyboardInterrupt exception. The loop portion …

python infinite-loop keyboardinterrupt try-except systemexit
Weird Try-Except-Else-Finally behavior with Return statements

This is some code that is behaving peculiarly. This is a simplified version of the behavior that I've written. This …

python try-except
How to catch empty user input using a try and except in python?

I am trying to figure out how I can catch empty user input using a try and except. If you …

python try-except
Why doesn't this python keyboard interrupt work? (in pycharm)

My python try/except loop does not seem to trigger a keyboard interrupt when Ctrl + C is pressed while debugging …

python pycharm try-except keyboardinterrupt
Python get an error code from exception

In python, I have code that handles exceptions and prints error codes and messages. try: somecode() #raises NameError except Exception …

python exception try-except
Ignore exception in Python

I have try-except block in python, and I want to do nothing when exception occurs. My code is as follows: …

python try-except
Handling Exceptions in Python 3.6

I am trying to handle exceptions in Python 3.6. I want to handle every possible exception and print the exception. When …

python exception python-3.6 try-except
Print exception with stack trace to file

I'm trying to put a simple log into my script. This log should tell me where is the error and …

python exception try-catch try-except
Exception AttributeError: "'NoneType' object has no attribute 'path'" in

I am debugging python code (python2.7.12) as my code works but I get NULL for all variables when streaming tweets …

python-2.7 attributeerror try-except