Returning individual string representation of all objects in list of objects
<p><strong>Is it possible to return the string representation (using __str__) of all objects in a list of objects from a different classes own __str__ function?</strong></p>

<p>Say I have a class that contains all methods being performed on Bar objects. Call this class Foo. Then:</p>

<pre><code>class Foo:
    def __init__(self):
        self.bars = []  # contains Bar objects

    def __str__(self):
        return "This is the Foo object"

class Bar:
    def __init__(self, arg1):
        self.arg1 = arg1

    def __str__(self):
        return "This is Bar object: " + arg1

def main():
    foo = Foo()
    print(str(foo))
</code></pre>

<p>I want to print the string representation of all of the objects in self.bars <strong>WHEN</strong> I call main(), since creating an instance of the Bar object would not give me access to the string representation of all of the objects in self.bars.</p>

<p>To clarify, I am not asking the same question as in <a href="https://stackoverflow.com/questions/3558474/how-to-apply-str-function-when-printing-a-list-of-objects-in-python">this</a> post relating to the need of <strong>__repr__</strong>. Instead, I want to return each object's string representation individually, as with a for loop.</p>

<p>Is there anyway to do this, reasonably or unreasonably?</p>