<p>I wrote a piece of code to convert PHP's striplashes into valid Python [backslash] escapes:</p>

<pre><code>cleaned = stringwithslashes
cleaned = cleaned.replace('\\n', '\n')
cleaned = cleaned.replace('\\r', '\n')
cleaned = cleaned.replace('\\', '')
</code></pre>

<p>How can I condense it? </p>

You can obviously concatenate everything together:
```
```
cleaned = stringwithslashes.replace("\\n","\n").replace("\\r","\n").replace("\\","")
```
```
Is that what you were after? Or were you hoping for something more terse?