[Python-ideas] Introduce some obvious way to encode and decode filenames from Python code
Ned Batchelder
ned at nedbatchelder.com
Tue Jul 17 15:59:32 CEST 2012
On 7/16/2012 11:49 AM, Antoine Pitrou wrote:
> 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
It's too bad these are not called os.path.encode() and os.path.decode(),
since they fit so nicely into os.path's charter of manipulating strings
representing file paths.
--Ned.
> Regards
>
> Antoine.
>
>
More information about the Python-ideas
mailing list