[Python-ideas] Introduce some obvious way to encode and decode filenames from Python code
Antoine Pitrou
solipsis at pitrou.net
Mon Jul 16 17:49:56 CEST 2012
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
Regards
Antoine.
--
Software development and contracting: http://pro.pitrou.net
More information about the Python-ideas
mailing list