I know the Python thing that if I'm using interactive interpreter and I write '\\ ' it prints '\\ ' but if if I write print '\\ ' it prints '\ '.
What I'm trying to do is (in a script called p.py):
import os
os.system('echo ' + 'string with spaces'.replace(' ', '\ '))
obviously it won't let me do this. I mean, Python manages to add TWO backslashes instead of one but I think it does so only in interactive mode, but the terminal, when passed special chars like \, ignores them.
So that, as the output of the provious code, I get:
local:$ string with spaces
and not
local:$ string\ with\ spaces
I already tried hardcoded strings and everything else in Python, but I guess the problem is with shell strings.
How could I solve this?
It it can help to find alteratives solutions, what I'm trying to do is moving a file from python with the mv command, and this file has spaces in its name.