If you're writing code like this:
try:
foo = somevar.getBlah()["xyz"].split(".")[-1].decode("ascii", "replace")
except:
pass
Please stop! You're killing the rain forest!
import urllib2, BeautifulSoup
def filtry(f):
def _(args, *kwargs):
try:
return f(args, *kwargs)
except:
return False
return _
@filtry
def myfilter(tag):
return tag.contents[0]['alt'].startswith("Exhibit")
hrefs = [tag['href'] for tag in BeautifulSoup.BeautifulSoup(urllib2.urlopen("foo").read()).findAll(myfilter)]
Please keep comments appropriate. I reserve the right to remove anonymous comments, flames, spammy, inappropriate, and other comments that I deem to be worth removing.
Note: New comments get placed in a "draft" status and will NOT show up on the site until I explicitly approve it. Usually that happens within 24 hours, but sometimes I go away and it takes a day or two.
Note 2: There is now a preview button for those of you who want to see a preview! However, it doesn't quite work the way you'd think it should work. I'll look into adjusting it some day.
Note 3: If you can't for some reason post a comment, send me an email: willg at bluesock dot org.
All contents Copyright 1996 to 2008 Will Guaraldi.
This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.