def match(self, attr, val):
self._lock.acquire()<EOL>try:<EOL><INDENT>for x in self:<EOL><INDENT>if getattr(x, attr) == val:<EOL><INDENT>return x<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>self._lock.release()<EOL><DEDENT>
lookup object in directory with attribute matching value