logic seemed to be broken (only filter out strings which have a 'strip'

attribute

string in python 3 have both attributes, '__iter__' and '__getitem'. Old
syntax therefore split up strings into characters
This commit is contained in:
Martin Diehl 2018-07-19 15:46:14 +02:00
parent beb418eb44
commit 6dd970dfe0
1 changed files with 2 additions and 2 deletions

View File

@ -36,8 +36,8 @@ class bcolors:
def srepr(arg,glue = '\n'):
"""Joins arguments as individual lines"""
if (not hasattr(arg, "strip") and
hasattr(arg, "__getitem__") or
hasattr(arg, "__iter__")):
(hasattr(arg, "__getitem__") or
hasattr(arg, "__iter__"))):
return glue.join(str(x) for x in arg)
return arg if isinstance(arg,str) else repr(arg)