Most viewed recipes tagged "find"http://code.activestate.com/recipes/tags/find/views/2013-09-17T08:48:07-07:00ActiveState Code RecipesFind the oldest (or yougest) of a list of files (Python)
2009-06-10T16:08:13-07:00Micah Elliotthttp://code.activestate.com/recipes/users/2649403/http://code.activestate.com/recipes/576804-find-the-oldest-or-yougest-of-a-list-of-files/
<p style="color: grey">
Python
recipe 576804
by <a href="/recipes/users/2649403/">Micah Elliott</a>
(<a href="/recipes/tags/age/">age</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/queue/">queue</a>).
</p>
<p>Sometimes you need to perform an operation on the oldest of a set of files. Using <em>get_oldest_file</em> you could implement an age-based priority queue that processes files from oldest to newest. The list of files you pass in may be from a <em>glob</em> of a single directory or some more elaborate search routine.</p>
Find Multiple Elements In a List (Python)
2011-11-05T23:40:41-07:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/577943-find-multiple-elements-in-a-list/
<p style="color: grey">
Python
recipe 577943
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/enumerate/">enumerate</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/search_list/">search_list</a>).
</p>
<p>This algorithm searches for more than one element in a list. The input is a list that you want to search through and a list of elements that you want to search for. The output is a multidimensional list with the positions of the elements you are searching for in the search list in the order that you listed them. </p>
Find file in subdirectory (Python)
2010-02-02T11:35:53-08:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577027-find-file-in-subdirectory/
<p style="color: grey">
Python
recipe 577027
by <a href="/recipes/users/4172918/">Daniel Cohn</a>
(<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/subdirectory/">subdirectory</a>).
Revision 2.
</p>
<p>Walks subdirectories to find a file and returns . Default start location is the current working directory. Optionally, a different directory can be set as the search's starting location.</p>
Python Multidimensional List Searcher (Python)
2011-10-29T22:21:39-07:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/577929-python-multidimensional-list-searcher/
<p style="color: grey">
Python
recipe 577929
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/element/">element</a>, <a href="/recipes/tags/elements/">elements</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/finder/">finder</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/search/">search</a>).
</p>
<p>This module/function lets you find a 2 dimensional list of indices for elements you are looking for in a super list.
Example:</p>
<p>find([1,1,1,2,1,2,3,3],[1,2,3])</p>
<p>returns: [[0, 1, 2, 4], [3, 5], [6, 7]]</p>
Search sequences for sub-sequence (Python)
2011-08-19T05:17:00-07:00Steven D'Apranohttp://code.activestate.com/recipes/users/4172944/http://code.activestate.com/recipes/577850-search-sequences-for-sub-sequence/
<p style="color: grey">
Python
recipe 577850
by <a href="/recipes/users/4172944/">Steven D'Aprano</a>
(<a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/searching/">searching</a>, <a href="/recipes/tags/sequence/">sequence</a>, <a href="/recipes/tags/string/">string</a>, <a href="/recipes/tags/sublist/">sublist</a>, <a href="/recipes/tags/substring/">substring</a>).
</p>
<p>The list and tuple index() method and <code>in</code> operator test for element containment, unlike similar tests for strings, which checks for sub-strings:</p>
<pre class="prettyprint"><code>>>> "12" in "0123"
True
>>> [1, 2] in [0, 1, 2, 3]
False
</code></pre>
<p>These two functions, search and rsearch, act like str.find() except they operate on any arbitrary sequence such as lists:</p>
<pre class="prettyprint"><code>>>> search([1, "a", "b", 2, 3], ["b", 2])
2
</code></pre>
get index of element in list using identity (Python)
2008-08-16T19:41:37-07:00nosklohttp://code.activestate.com/recipes/users/4166478/http://code.activestate.com/recipes/576426-get-index-of-element-in-list-using-identity/
<p style="color: grey">
Python
recipe 576426
by <a href="/recipes/users/4166478/">nosklo</a>
(<a href="/recipes/tags/compare/">compare</a>, <a href="/recipes/tags/comparision/">comparision</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/identity/">identity</a>, <a href="/recipes/tags/index/">index</a>, <a href="/recipes/tags/is/">is</a>, <a href="/recipes/tags/same_object/">same_object</a>, <a href="/recipes/tags/search/">search</a>).
Revision 2.
</p>
<p>my_list.index(element) returns the index of the element using common comparision (as in == or __eq__() or __cmp__()). If you need to find an element on the list using identity comparing (is) then this function can do it for you</p>
Build sqlite3 database like a locatedb (Python)
2009-11-19T17:20:52-08:00Keisuke URAGOhttp://code.activestate.com/recipes/users/668964/http://code.activestate.com/recipes/576960-build-sqlite3-database-like-a-locatedb/
<p style="color: grey">
Python
recipe 576960
by <a href="/recipes/users/668964/">Keisuke URAGO</a>
(<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/locatedb/">locatedb</a>).
Revision 2.
</p>
<p>This recipe is "updatedb" like command.</p>
find + grep (Bash)
2013-09-17T08:48:07-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/578661-find-grep/
<p style="color: grey">
Bash
recipe 578661
by <a href="/recipes/users/4184815/">yota</a>
(<a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/zsh/">zsh</a>).
Revision 2.
</p>
<p>look for a text pattern in files defined by a pattern.
First argument is passed to the find command, second one to the grep</p>
<p>./find_n_grep.sh '*.py' 'dict'</p>
<p>more over, it sort by date.</p>
Prints full name of all occurrences of given filename in your PATH (Python)
2009-06-29T15:20:10-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/576823-prints-full-name-of-all-occurrences-of-given-filen/
<p style="color: grey">
Python
recipe 576823
by <a href="/recipes/users/4170919/">Ben Hoyt</a>
(<a href="/recipes/tags/filename/">filename</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/which/">which</a>).
</p>
<p>Simple program to print the full name of all occurrences of the given filename in your PATH. Kind of like the Unix "which" utility, but works for DLLs and other files as well.</p>
<p>Usage: findinpath.py filename</p>