Popular Python recipes tagged "walk"http://code.activestate.com/recipes/langs/python/tags/walk/2013-05-28T07:21:28-07:00ActiveState Code Recipeslndir.py (short python version of the BSD/X11 lndir utility) (Python) 2013-05-28T07:21:28-07:00Mike 'Fuzzy' Partinhttp://code.activestate.com/recipes/users/4179778/http://code.activestate.com/recipes/578535-lndirpy-short-python-version-of-the-bsdx11-lndir-u/ <p style="color: grey"> Python recipe 578535 by <a href="/recipes/users/4179778/">Mike 'Fuzzy' Partin</a> (<a href="/recipes/tags/directories/">directories</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/os_walk/">os_walk</a>, <a href="/recipes/tags/sysadmin/">sysadmin</a>, <a href="/recipes/tags/walk/">walk</a>). Revision 2. </p> <p>This should be valid for Python 2.6 and up, including the 3.x series.</p> Recursively walk Python objects (Python) 2011-12-23T22:10:38-08:00Yaniv Akninhttp://code.activestate.com/recipes/users/4180246/http://code.activestate.com/recipes/577982-recursively-walk-python-objects/ <p style="color: grey"> Python recipe 577982 by <a href="/recipes/users/4180246/">Yaniv Aknin</a> (<a href="/recipes/tags/container/">container</a>, <a href="/recipes/tags/recursive/">recursive</a>, <a href="/recipes/tags/recursive_iterator/">recursive_iterator</a>, <a href="/recipes/tags/walk/">walk</a>). Revision 2. </p> <p>A small function that walks over pretty much any Python object and yields the objects contained within (if any) along with the path to reach them. I wrote it and am using it to validate a deserialized data-structure, but you can probably use it for many things.</p> Create and apply filters to lists of file paths (Python) 2012-03-20T21:17:26-07:00eysihttp://code.activestate.com/recipes/users/4177096/http://code.activestate.com/recipes/578084-create-and-apply-filters-to-lists-of-file-paths/ <p style="color: grey"> Python recipe 578084 by <a href="/recipes/users/4177096/">eysi</a> (<a href="/recipes/tags/blacklist/">blacklist</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/filter/">filter</a>, <a href="/recipes/tags/walk/">walk</a>, <a href="/recipes/tags/whitelist/">whitelist</a>, <a href="/recipes/tags/yield/">yield</a>). Revision 2. </p> <p>An experiment with filtering lists of files, documentation is written directly into the code.</p> file path generator from path patterns (Python) 2010-07-09T19:10:59-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577230-file-path-generator-from-path-patterns/ <p style="color: grey"> Python recipe 577230 by <a href="/recipes/users/4173505/">Trent Mick</a> (<a href="/recipes/tags/cli/">cli</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/paths/">paths</a>, <a href="/recipes/tags/walk/">walk</a>). Revision 4. </p> <p>Provides a <code>_paths_from_path_patterns</code> that will generate a list of paths from a list of path patterns. A "path pattern" can include glob chars. By default it generates a recursive listing of file paths, but: recursion can be turned off, file and/or dir paths can be listed. It supports a list of glob exclusions or inclusions.</p> <p>This function makes it easy to implement typical "-r|--recursive" and "-x|--exclude" options for command-line scripts that work on given file paths. See <a href="#block-1">example usages below</a>.</p> <p>Note: I use a leading <code>_</code> on function names because my typical usage of my recipes is as re-usable <em>internal</em> functions in Python modules.</p>