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 adict) James -- http://mail.python.org/mailman/listinfo/python-list