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
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
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)
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
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)