diff options
author | YAMAMOTO Takashi <yamamoto@valinux.co.jp> | 2013-07-22 08:50:33 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-07-22 22:27:51 +0900 |
commit | f3e70d440b5bdbf82ee708db553a50eb915c4e0e (patch) | |
tree | 3b7deeaade6d8da0c707063a457851c124a4b539 | |
parent | ffc1e60df48f1d23c51711f48804fa9d023010aa (diff) |
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>
-rw-r--r-- | ryu/lib/stringify.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/ryu/lib/stringify.py b/ryu/lib/stringify.py index 3e1b41b9..5766f4ac 100644 --- a/ryu/lib/stringify.py +++ b/ryu/lib/stringify.py @@ -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 |