[Python-ideas] Introduce some obvious way to encode and decode filenames from Python code
Sven Marnach
sven at marnach.net
Mon Jul 16 19:04:41 CEST 2012
Antoine Pitrou schrieb am Mon, 16. Jul 2012, um 17:49:56 +0200:
> On Mon, 16 Jul 2012 15:49:52 +0100
> Sven Marnach <sven at marnach.net> wrote:
> > Currently, there is no obvious way to encode a filename in the default
> > filesystem encoding. To pipe some filenames to the stdin of a
> > subprocess, I effectively used
> >
> > encoded_name = file_name.encode(sys.getfilesystemencoding())
>
> Well, how about os.fsencode() and os.fsdecode()?
>
> http://docs.python.org/dev/library/os.html#os.fsencode
Oh, great, there they are! I think these functions should be
mentioned in these sections to make them easier to find:
[1]: http://docs.python.org/dev/library/os.html#file-names-command-line-arguments-and-environment-variables
[2]: http://docs.python.org/dev/library/sys.html#sys.getfilesystemencoding
[3]: http://docs.python.org/dev/howto/unicode.html#unicode-filenames
I'll post an issue on the issue tracker.
Cheers,
Sven
More information about the Python-ideas
mailing list