3 examples of 'search in list python' in Python

Every line of 'search in list python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
5def _find_dict_in_list(list_of_dict, key, val):
6 """Given a list of dictionaries, return the first dictionary that has the
7 given key:value pair.
8 """
9 try:
10 for d in list_of_dict:
11 if (key, val) in d.items():
12 return d
13 except TypeError:
14 pass
328def search(self, lst):
329 """
330 Search for a node without looking on the filesystem
331
332 :param lst: path
333 :type lst: string or list of string
334 """
335 if isinstance(lst, str):
336 lst = [x for x in split_path(lst) if x and x != '.']
337
338 cur = self
339 try:
340 for x in lst:
341 if x == '..':
342 cur = cur.parent or cur
343 else:
344 cur = cur.children[x]
345 return cur
346 except:
347 pass
59def list_find(l, element):
60 for i, e in enumerate(l):
61 if e == element:
62 return i
63 return None

Related snippets