PEP ? os.listdir enhancement

Jeff Epler jepler at unpythonic.net
Wed Jun 22 18:27:06 CEST 2005


Why not just define the function yourself?  Not every 3-line function
needs to be built in.

def listdir_joined(path):
    return [os.path.join(path, entry) for entry in os.listdir(path)]

dirs = [x for x in listdir_joined(path) if os.path.isdir(x)]

path_size = [(x, getsize(x)) for x in listdir_joined(path) if os.path.isfile(x)]


Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050622/b59ff5f2/attachment.sig>


More information about the Python-list mailing list