try-except

Beginner Classes – Calling a variable name in a function and if I used a try/except properly

Beginner Classes – Calling a variable name in a function and if I used a try/except properly Question: I just started learning Python/coding in general. I tried to find an answer to this but couldn’t. So I created this code for a Class "Vehicle" in my lab: class Vehicle(object): def __init__(self, maxspeed, mileage, color="white"): self.maxspeed=maxspeed; …

Total answers: 3

throw exception to another exception in one def using python

throw exception to another exception in one def using python Question: I’ve function to calculate data and after successful calculation the mail has been send to user. but now I want to do error mapping for user interface to show error to users, so that they understand where exactly the error is getting, In their …

Total answers: 2

Exception handling in AWS – Explicitly ignore some errors?

Exception handling in AWS – Explicitly ignore some errors? Question: I have a Lambda function that’s used to verify the integrity of a file, but for simplicity sake, let’s just assume that it copies a file from a bucket into a bucket upon trigger (lambda gets triggered when it detects file ingestion). The problem that …

Total answers: 1

Using try after except is not working on Python

Using try after except is not working on Python Question: I’m doing exercise 4 on CS50P "outdated" and after trying to make the code work with if/else statements I came across a solution that used try/except for dealing with cases instead of if/else. In the following code I don’t understand why the second except gets …

Total answers: 1

try except block prints 'hello'

try except block prints 'hello' Question: I have a perculiar problem. I’m using the extract_msg package to analyse a bunch of .msg files. The package results in an NotImplementedError error when the .msg file contains attachtments. I’m using a try-except block to catch this error, but for some weird reason its prints "hello" for every …

Total answers: 1

Try… except is wrong

Try… except is wrong Question: I was working on a function that test functions and I found that y try except was wrong at all… In fact, when I am trying to test a sorting function (the one by selection) it returns me that the index was out of range and it’s not the case …

Total answers: 1

How to use multiple exceptions conditions properly?

How to use multiple exceptions conditions properly? Question: I am working with many files and this is an example of a smaller portion. Imagine I have my file names inside a list like this: filelist = ["file1.csv", "file2.csv", "file3.csv"] I would like to import them as a dataframe. If I am not able to do …

Total answers: 1

For loop does not continue after exception occurs on Python

For loop does not continue after exception occurs on Python Question: This piece of code runs on different threads for connected clients. When a client disconnects, the try-except block should raise an exception, and remove the client from the clients list (connectClients is also a list, I used this to prevent the error that occurs …

Total answers: 1

try/except if/else – how to replace 'None' output

try/except if/else – how to replace 'None' output Question: I am trying to write a function that will take a target number, and a matrix as its parameter, and will return the ‘co-ordinates’ of the target number. If the target number doesn’t exist, (-1, -1) will be returned. It is assumed there will only be …

Total answers: 2