Best way to extract from regex in if statement

Tim Chase python.list at
Sat Apr 4 04:32:55 CEST 2009

> Or in case you want to handle each regexp differently, you can
> construct a dict {regexp : callback_function} that picks the right
> action depending on which regexp matched. 

One word of caution:  dicts are unsorted, so if more than one 
regexp can match a given line, they either need to map to the 
same function, or you need to use a list of regexp-to-functions 
(see my previous post) for a determinate order.


More information about the Python-list mailing list