vendredi 1 septembre 2017

Multiple check for "None" - what would be the proper way in Python

I'm using BeautifulSoup for parsing html, I often find my self with the following code:

result.find("some_tag").attrs['some_attribute']

What would be the proper way to verify if find method didn't return None and also to check if there is a such key in attributes without nested "if" statement ?

thanks

Aucun commentaire:

Enregistrer un commentaire