What is the most idiomatic way to do the following?
def xstr(s): if s is None: return \'\' else: return s s = xstr(a) + xstr(b)
Use short circuit evaluation:
s = a or '' + b or ''
Since + is not a very good operation on strings, better use format strings:
s = "%s%s" % (a or '', b or '')