os.listdir() bug in WinXp. Calling with empty string
Bernhard Herzog
bh at intevation.de
Mon Oct 6 09:23:42 EDT 2003
bokr at oz.net (Bengt Richter) writes:
> On Sun, 5 Oct 2003 07:29:34 -0400, "John Roth" <newsgroups at jhrothjr.com> wrote:
>> The least surprising behavior
>>here is to simply list the current directory. In other words,
>>a null string would be equivalent to a string containing a single
>>dot.
>>
> +1
>
> That intuitively matches well with arg-less invocation of ls or dir.
-1
Passing an empty string isn't an argless call.
If you want os.listdir to be similar to ls, os.listdir() should be
equivalent to os.listdir(".") (currently the string argument is
required).
And for an empty string a brief test shows that ls with an empty string
as argument behaves just like os.listdir("") (both on GNU/Linux system):
$ ls ''
ls: : No such file or directory
>>> os.listdir("")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 2] No such file or directory: ''
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
Thuban http://thuban.intevation.org/
More information about the Python-list
mailing list