def get_display_name(entity):
    """
    Gets the display name for the given entity, if it's an :tl:`User`,
    :tl:`Chat` or :tl:`Channel`. Returns an empty string otherwise.
    """
    if isinstance(entity, types.User):
        if entity.last_name and entity.first_name:
            return '{} {}'.format(entity.first_name, entity.last_name)
        elif entity.first_name:
            return entity.first_name
        elif entity.last_name:
            return entity.last_name
        else:
            return ''

    elif isinstance(entity, (types.Chat, types.Channel)):
        return entity.title

    return ''
def get_display_name ( entity ) : if isinstance ( entity , types . User ) : if entity . last_name and entity . first_name : return '{} {}' . format ( entity . first_name , entity . last_name ) elif entity . first_name : return entity . first_name elif entity . last_name : return entity . last_name else : return '' elif isinstance ( entity , ( types . Chat , types . Channel ) ) : return entity . title return ''
Gets the display name for the given entity, if it's an :tl:`User`,
    :tl:`Chat` or :tl:`Channel`. Returns an empty string otherwise.