In some cases, the attribute will be there, and in others, it will not. I'm trying to check for an error in advance so my program will not fail. I'm currently using this code:
if stock.find_all("option") != AttributeError:
all_sizes = stock.find_all("option")
else:
print "Desired item has sold out"
Attempting to check for an error beforehand, however, I still get the following error.
if stock.find_all("option") != AttributeError:
AttributeError: 'NoneType' object has no attribute 'find_all'
Instead of the error and ending my program, I want it to simply print the message then terminate.