def dict_match(d, key, default=None):
 if ((key in d) and ('[' not in key)):
  return d[key]
 else:
  for (pattern, value) in iteritems(d):
   if fnmatchcase(key, pattern):
    return value
 return default

def dict_match ( d , key , default = None ) : if ( ( key in d ) and ( '[' not in key ) ) : return d [ key ] else : for ( pattern , value ) in iteritems ( d ) : if fnmatchcase ( key , pattern ) : return value return default
like __getitem__ but works as if the keys() are all filename patterns .