Quicker way than "try" and "except" ? - Python

Posted by RadiantHex on Stack Overflow See other posts from Stack Overflow or by RadiantHex
Published on 2010-03-14T19:43:09Z Indexed on 2010/03/14 20:15 UTC
Read the original article Hit count: 165

Filed under:
|

I'm often having code written as follows

try:
  self.title = item.title().content.string
except AttributeError, e:
  self.title = None

Is there a quicker way of dealing with this? a one-liner?

© Stack Overflow or respective owner

Related posts about python

Related posts about beautifulsoup