I'm creating a list of objects, and if any have some undesirable data while they're being initialized, I'd like to immediately cancel their initialization, and move on to the next object. Is there a best practice for something like this in Python?
data = [good, bad]
theList = [myObject(some_data) for some_data in data]
# I'd like myObject to determine if it should create itself, after some data parsing.
Should I just return nothing from __new__ ? Or do I just need to separate out the data validation logic from myObject..? Or..?
Thanks!
Context: Given a folder path, I'm checking a bunch of stuff in sequence (is the basename formatted correctly, if so, does a certain file exist, if so, parse it...etc)