\'Hello \' + (\'there\' if name is None else name)
Is the equivalent of
msg = \'Hello \' if name is None: msg += \'there\' else:
msg = 'Hello ' + ( 'there' if name is None else 'Neo' if name == 'Mr Anderson' else name )
This is a reiteration of several other answers, but with nicer formatting. I consider this most readable, and this is the approach I would use.