about __str__

TheFlyingDutchman zzbbaadd at aol.com
Thu Sep 20 18:17:17 EDT 2007


I read here recently that the __str__ method of a list calls the
__repr__ method of each of its members. So you need to add a __repr__
method to your class:

class CmterIDCmts:
    def __init__(self,commiterID,commits):
        self.commiterID_=long(commiterID)
        self.commits_=long(commits)

    def __str__(self):
        s=""
        s+="<"+str(self.commiterID_)+":"+str(self.commits_)+">"
        return s
    def __repr__(self):
        return self.__str__()





More information about the Python-list mailing list