stringify.StringifyMixin.__str__: simplify

simplify the code a bit.
suggested by Isaku Yamahata.
no functional changes are intended.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
YAMAMOTO Takashi 2013-07-22 08:50:33 +09:00 committed by FUJITA Tomonori
parent ffc1e60df4
commit f3e70d440b

View File

@ -53,13 +53,10 @@ class StringifyMixin(object):
return obj_python_attrs(self)
def __str__(self):
buf = ''
sep = ''
for k, v in self.stringify_attrs():
buf += sep
buf += "%s=%s" % (k, repr(v)) # repr() to escape binaries
sep = ','
return self.__class__.__name__ + '(' + buf + ')'
# repr() to escape binaries
return self.__class__.__name__ + '(' + \
','.join("%s=%s" % (k, repr(v)) for k, v in
self.stringify_attrs()) + ')'
__repr__ = __str__ # note: str(list) uses __repr__ for elements
@classmethod