PEP ? os.listdir enhancement

Peter Otten __peter__ at
Thu Jun 23 13:46:24 CEST 2005

Konstantin Veretennicov wrote:

> On 6/22/05, Riccardo Galli <riccardo_cut1 at> wrote:
>> I propose to add an 'abs' keyword which would make os.listdir return the
>> absolute path of files instead of a relative path.
> What about os.listdir(dir='relative/path', abs=True)? Should listdir
> call abspath on results? Should we add another keyword rel? Would it
> complicate listdir unnecessarily?
> - kv

I'm in favour of Riccardo's suggestion, but I think he's got the name of the
keyword wrong. The signature should be

listdir(path, with_path=False)

and cater absolute and relative paths alike. 

The need for such an enhancement is not particularly pressing, as
workarounds abound. Here's another one:

>>> glob.glob("/usr/lib/games/../games/*")


More information about the Python-list mailing list