Is there a way to mark a string such that it will not trigger python’s % string substitution?
In particular, I’m attempting to download a file whose name includes a % using the python sftp module. The sftp module attempts to log the name of the file using the logging module:
self.logger.log(level, msg, *args)
and logging complains about string formatting because of the % signs:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 328, in getMessage
msg = msg % self.args
TypeError: not enough arguments for format string
So: since I don’t control the filename nor the sftp module, can I mark the filename as not participating in string substitution?
mystring.replace('%', '%%')might suit your needs.%%escapes a%.