glob.glob standardization

billiejoex gnewsg at gmail.com
Wed Jun 27 18:06:40 EDT 2007


os.listdir(path) return a list of file names independently if the path-
argument used is absolute or relative:

>>> os.getcwd()
'/home/user'
>>> os.listdir('Desktop')
['file.py']
>>> os.listdir('/home/user/Desktop')
['file.py']

glob.glob, instead, return file names only if given path is relative:

>>> os.chdir('Desktop')
>>> os.getcwd()
'/home/user/Desktop
>>> glob.glob("*")
['file.py']

...and absolute file names if given path is absolute:

>>> glob.glob('/home/user/Desktop/*')
['/home/user/Desktop/file.py']

Don't you think it would be more convenient for glob.glob to return
file names only in any case, like os.listdir do?




More information about the Python-list mailing list