Hello After downloading a web page, I need to search for several patterns, and if found, extract information and put them into a database.
To avoid a bunch of "if m", I figured maybe I could use a dictionary to hold the patterns, and loop through it: ====== pattern = {} pattern["pattern1"] = ">.+?</td>.+?>(.+?)</td>" for key,value in pattern.items(): response = ">whatever</td>.+?>Blababla</td>" #AttributeError: 'str' object has no attribute 'search' m = key.search(response) if m: print key + "#" + value ====== Is there a way to use a dictionary this way, or am I stuck with copy/pasting blocks of "if m:"? Thank you. -- http://mail.python.org/mailman/listinfo/python-list