PEP ? os.listdir enhancement

Peter Otten __peter__ at web.de
Thu Jun 23 07:46:24 EDT 2005


Konstantin Veretennicov wrote:

> On 6/22/05, Riccardo Galli <riccardo_cut1 at cut2_sideralis.net> 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/*")
['/usr/lib/games/../games/schwarzerpeter']


Peter




More information about the Python-list mailing list