Yes, there is. The Python way is even better.
Yes, there is. The Python way is even better. There are three possibilities: 1) Like File.listFiles(): Python has the function os.
Listdir(path). It works like the Java method. 2) pathname pattern expansion with glob: The module glob contains functions to list files on the file system using Unix shell like pattern, e.g. Files = glob.
Glob('/usr/joe/*. Gif') 3) File Traversal with walk: Really nice is the os. Walk function of Python.
The walk method returns a generation function that recursively list all directories and files below a given starting path. An Example: import os from os. Path import join for root, dirs, files in os.
Walk('/usr'): print "Current directory", root print "Sub directories", dirs print "Files", files You can even on the fly remove directories from "dirs" to avoid walking to that dir: if "joe" in dirs: dirs. Remove("joe") to avoid walking into directories called "joe". Listdir and walk are documented here.
Glob is documented here.
As a long-time Pythonista, I have to say the path/file manipulation functions in the std library are sub-par: they are not object-oriented and they reflect an obsolete, lets-wrap-OS-system-functions-without-thinking philosophy. I'd heartily recommend the 'path' module as a wrapper (around os, os. Path, glob and tempfile if you must know): much nicer and OOPy: pypi.python.org/pypi/path.py/2.2 This is walk() with the path module: dir = path(os.
Environ'HOME') for f in dir.walk(): if f.isfile() and f. Endswith('~'): f.remove().
Try "listdir()" in the os module (docs): import os print os. Listdir('. ').
Straight from Python's Refererence Library >>> import glob >>> glob. Glob('. /0-9.
*') '. /1. Gif', '.
/2. Txt' >>> glob. Glob('*.
Gif') '1. Gif', 'card. Gif' >>> glob.
Glob('?. Gif') '1. Gif'.
Take a look at os.walk() and the examples here. With os.walk() you can easily process a whole directory tree. An example from the link above... # Delete everything reachable from the directory named in 'top', # assuming there are no symbolic links.
# CAUTION: This is dangerous! For example, if top == '/', it # could delete all your disk files. Import os for root, dirs, files in os.
Walk(top, topdown=False): for name in files: os. Remove(os.path. Join(root, name)) for name in dirs: os.
Rmdir(os.path. Join(root, name)).
Use os.path. Walk if you want subdirectories as well. Walk(top, func, arg) Directory tree walk with callback function.
For each directory in the directory tree rooted at top (including top itself, but excluding '. ' and '..'), call func(arg, dirname, fnames). Dirname is the name of the directory, and fnames a list of the names of the files and subdirectories in dirname (excluding '.' and '..').
Func may modify the fnames list in-place (e.g. Via del or slice assignment), and walk will only recurse into the subdirectories whose names remain in fnames; this can be used to implement a filter, or to impose a specific order of visiting.No semantics are defined for, or required of, arg, beyond that arg is always passed to func. It can be used, e.g. , to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common.
I'd recommend against os.path. Walk as it is being removed in Python 3.0. Os.
Walk is simpler, anyway, or at least I find it simpler.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.