def countfiles(path, recurse=False):
    """Returns the number of files under the given directory path."""
    if not op.isdir(path):
        return 0
    count = 0
    for r,ds,fs in os.walk(path):
        count += len(fs)
        if not recurse:
            break
    return count
def countfiles ( path , recurse = False ) : if not op . isdir ( path ) : return 0 count = 0 for r , ds , fs in os . walk ( path ) : count += len ( fs ) if not recurse : break return count
Returns the number of files under the given directory path.