I\'m often having code written as follows
try: self.title = item.title().content.string except AttributeError, e: self.title = None
In one line, although I’d only recommend this in 5% of all use cases.
self.title = item.title().content.string if hasattr(item, 'title') else None