Question: Suppose I have the path directory `pathname`. I can print all the files in that directory by doing 

```
glob.glob('*')

```

but that doesn't print out the files in the subdirectories (such as `dir/file1.txt`)

Is it possible to print out all files in this directory as well as all subdirectories?

Answer: 
It's only a little more difficult using `os.walk`

```
import os
for dirpath, dirnames, filenames in os.walk('.'):
    for f in filenames:
        print os.path.join(dirpath, f)

```

You can also express this as a generator expression

```
for filename in (os.path.join(dp, f) for dp, dn, fn in os.walk('.') for f in fn):
    # do something with filename

```
You want to use os.walk.

Example:

```
for (dirname, subs, files) in os.walk('.'):
    print('[' + dirname + ']')
    for fname in files:
        print(os.path.join(dirname, fname))

```

See [here for more info](http://docs.python.org/3.3/library/os.html#files-and-directories)