R. David Murray added the comment: Parens do not cause lazy evaluation unless what is parenthesized is a generator comprehension. An expanded if solution is the correct one.
If Vinay prefers a one liner, I think you could also write: _levelToName.get(level) or _nameToLevel.get(level) or ("Level %s" % level) Because we know we get back either a True string or None, I don't think there's any ambiguity there. ---------- nosy: +r.david.murray, vinay.sajip _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27937> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com