Python inline elif possible?

Use a dictionary to perform a mapping:

srepr = "'Modify " + {"p": "Pointer", "v": "value"}.get(self.register, "Unknown")

(by the way, instead of '\'...' you can use "'... for a bit more clarity.


msg = "Hi " + ("there" if not name else ("Neo" if name == "Anderson" else name))

I think that's pretty unreadable, though.


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.