Baptiste Carvello <[EMAIL PROTECTED]> added the comment:

If, as I understand, it is the application's job to call listdir with
bytes or unicode depending on the platform, it might be useful to have a
function in the os module telling whether the filesystem is bytes of
unicode-native. 

That way, the idiom for doing something to all files in a given
directory would read:

>>> directory="my_direcory"
... if not os.is_filesystem_unicode():
...     directory=directory.encode(sys.stdin.encoding)
... for name in os.listdir(directory):
...     f=open(name)
... # do something
...     f.close()

and it would work on all platforms, even if one of the filenames is not
in the locale's normal encoding.

If this idiom is correct, it could also be useful to include it in the
module documentation so that application authors know what they are
supposed to do.

----------
nosy: +zegreek

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3187>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to