billiejoex <[EMAIL PROTECTED]> wrote:
>...
>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/D
> Don't you think it would be more convenient for glob.glob to return
> file names only in any case, like os.listdir do?
No. Use glob.glob1 if you want a list of files.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list
billiejoex <[EMAIL PROTECTED]> wrote:
> Don't you think it would be more convenient for glob.glob to return
> file names only in any case, like os.listdir do?
AFAIK it's a wanted behavior. The doc says:
"""
Notice how any leading components of the path are preserved.
"""
--
Lawrence, oluyede.o
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: