How to overload __str__ operation so str("test") returns "test"
<p>I'm trying to overload the <strong>str</strong> operation so that when I do str(string) it keeps the quotations.</p>

<p>ex:
str("test")
returns test</p>

<p>I want it to return "test"</p>

<p>Heres what I have written, any help would be very much appreciated!</p>

<pre><code>class Action(MalmoAgent):
    def __init__(self, command = '', value = 0):
        self.__command =  command
        self.__value = value
    def __str__(self):
        return ' " ' + self + ' " '
</code></pre>

<p>Just format your string</p>

<pre><code>...  def __str__(self):
...   return '"%s"' % self.whatever
</code></pre>

python string operator-overloading