I have a question, is there a way to "force" repr() to create always single quotes around a string?
This happens when I only use repr()
print repr("test")
'test'
print repr("test'")
"test'"
print repr("test\"")
'test"'
print repr("test'\"")
'test\'"'
so the last one actually does, what I want, but I don't want to add always \\" to get the single quotes.
Edit: I am not going to mark an answer as accepted since, as pointed out by @martijn-pieters, I was using repr() for purposes it is not intended for.
Well, if your object is always a string you could do this:
But as Martijn Pieters asked I'm curious as to your use case here.