You want `md.get('ToUserName', message['from_addr'])` here, unless you explicitly want to use `message['from_addr']` in the case where `ToUserName` is present but evaluates to `False` (in which case you should document this intent).