On 9 September 2015 at 15:41, Wolfgang Maier wolfgang.maier@biologie.uni-freiburg.de wrote:
def unpack_format (iterable, format_spec=None): if format_spec: try: sep, element_fmt = format_spec.split('|', 1) except ValueError: raise TypeError('Invalid format_spec for iterable formatting') return sep.join(format(e, element_fmt) for e in iterable) else: return ' '.join(format(e) for e in iterable)
From the docs, "The default format_spec is an empty string which
usually gives the same effect as calling str(value)"
So you can just use format_spec='' and avoid the extra conditional logic. Paul