Q:

How to check for pipes in directory traversal?

I have a Python program that traverses a directory and generates md5sums. On one file it gets stuck. Running ls -lA I found that it has the attributes prw-------. Some googling later I found that this indicates a pipe. 
How to check for pipes in my traversal? I just want to skip this file.

My code for traversing is:
for dirpath, _, files in walk(folder):
    for fname in files:
        print join(dirpath, fname)
        if not islink(join(dirpath, fname)):
            # do something with the file, here I pass it to myClass.
            myClass.addFile(dirpath, fname)

A:

You don't really need to test for pipes explicitly, you only want to look for files.
Use os.path.isfile(); it'll return False for a pipe, but True for an actual file:
$ ls -l
total 0
-rw-rw-r-- 1 mj mj 0 Sep  7 12:27 actualfile
prw-rw-r-- 1 mj mj 0 Sep  7 12:25 pipe

>>> os.path.isfile('pipe')
False
>>> os.path.isfile('actualfile')
True

