[ home | blog home | recent activity ]
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!
Comments:
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)]
Post a new comment:
Three things:
If you can't for some reason post a comment, send me an email: willg at bluesock dot org.
pyblosxom::1.5-dev git-master
Copyright 1996 to 2012, Will Guaraldi Kahn-Greene, under the Creative Commons BY-SA 3.0 license

Will's Blog by William Kahn-Greene is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.