Re: about __str__

2007-09-24 Thread Bruno Desthuilliers
Mikael Olofsson a écrit : > Bruno Desthuilliers wrote: >> def __str__(self): >> return "<%s:%s>" % (self.commiterID_, self.commits_) > > I would write that in the following way: > > def __str__(self): >return "<%(commiterID_)s:%(commits_)s>" % self.__dict__ > > More explicit IMHO. And ea

Re: about __str__

2007-09-24 Thread Mikael Olofsson
Bruno Desthuilliers wrote: > def __str__(self): > return "<%s:%s>" % (self.commiterID_, self.commits_) I would write that in the following way: def __str__(self): return "<%(commiterID_)s:%(commits_)s>" % self.__dict__ More explicit IMHO. And easier to maintain, especially if the string

Re: about __str__

2007-09-21 Thread Bruno Desthuilliers
Konstantinos Pachopoulos a écrit : > Hi, > i have the following class: > === > class CmterIDCmts: def __init__(self,commiterID,commits): >self.commiterID_=long(commiterID) >self.commits_=long(commits) > >def __str__(self)

Re: about __str__

2007-09-20 Thread Paul Hankin
On Sep 20, 10:08 pm, Konstantinos Pachopoulos <[EMAIL PROTECTED]> wrote: > > The __str__ method of "list" doesn't seem to call the __str__ method of > the objects > ie, __str__ is not equicalent to the Java toString() method... Anyway, > how can i fix this? For whatever reason, __str__ of list

Re: about __str__

2007-09-20 Thread TheFlyingDutchman
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)