[New-bugs-announce] [issue28817] Provide method PurePath.quote() that calls shlex.quote

Ram Rachum report at bugs.python.org
Mon Nov 28 05:41:44 EST 2016


New submission from Ram Rachum:

I have a a PurePath object like so:

    path = PurePath('/home/my awesome user/file.txt')

I'm SSHing into a server and I want to remove the file. So I have to do this: 

    ssh_client.run(f'/bin/rm {shlex.quote(str(path))}')
    
Which is really long and ugly. 

I suggested in issue28623 that shlex.quote could just take a Path argument, and in issue28811 that __str__ would use shlex.quote, and it was rejected too. 

My next suggestion: Implement PurePath.quote() method that calls shlex.quote() on the path. What do you think?

----------
components: Library (Lib)
messages: 281858
nosy: cool-RR, pitrou
priority: normal
severity: normal
status: open
title: Provide method PurePath.quote() that calls shlex.quote
type: enhancement
versions: Python 3.6

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


More information about the New-bugs-announce mailing list