searching dict key with reqex

2007-08-21 Thread james_027
hi, can I use regex instead of a plain string with this kind of syntax ... 'name' in a_dictionary something like r'name_\D+' in a_dictionary? Thanks james -- http://mail.python.org/mailman/listinfo/python-list

Re: searching dict key with reqex

2007-08-21 Thread James Stroud
james_027 wrote: hi, can I use regex instead of a plain string with this kind of syntax ... 'name' in a_dictionary something like r'name_\D+' in a_dictionary? Thanks james This makes it a one-liner: import re def rgxindict(rgx, adict): return any(re.match(rgx,k) for k in