[issue18087] os.listdir don't show hidden option

Dražen Lučanin report at bugs.python.org
Wed May 29 14:00:22 CEST 2013


Dražen Lučanin added the comment:

@Amaury Forgeot d'Arc - well, the '.' and '..' special files are
detected directly in the listdir code, so I don't think there is any
need to interleave this logic any deeper (such as os.path.ishidden).

@Antoine Pitrou - a one-liner, but it unnecessarily complicates the
code - an optional argument is a much more elegant solution in my
opinion. Regarding the *~ files - they are backup files, not hidden
files (same as e.g. #somefile# files that Emacs generates). These are
shown by ls, just hidden in some desktop environments.

Another point is that dotfiles are really something of a special case
(especially to programmers http://dotfiles.github.io/ ), because many
programs store configurations and special data inside and it makes
sense to allow users to omit these.

I know I could use glob, I am currently doing that, but it seems like
bad practice to switch to a different module that is also in the
standard library, just it has the "dotfile detection magic" and os
doesn't. The fact is that dotfiles do have special a meaning in Unix
operating systems and the os module documentation states that some
functionality is only tailored to Unix-based platforms
(http://docs.python.org/2/library/os.html):

    An “Availability: Unix” note means that this function is commonly
found on Unix systems. It does not make any claims about its existence
on a specific operating system.

On Wed, May 29, 2013 at 1:05 PM, Serhiy Storchaka
<report at bugs.python.org> wrote:
>
> Changes by Serhiy Storchaka <storchaka at gmail.com>:
>
>
> ----------
> resolution:  -> rejected
> stage:  -> committed/rejected
> status: open -> closed
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue18087>
> _______________________________________

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18087>
_______________________________________


More information about the Python-bugs-list mailing list