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>

<pre><code>class MalmoAgent():
    pass

class Action(MalmoAgent):
    def __init__(self, command='', value=0):
        self.__command = command
        self.__value = value

    def __str__(self):
        return '"' + super(Action, self).__str__() + '"'


thing = Action()

print("I have a", thing, "called thing.")
</code></pre>

<p><strong>OUTPUT</strong></p>

<pre><code>I have a "&lt;__main__.Action object at 0x101ae9a90&gt;" called thing.
</code></pre>

python string operator-overloading