Gets the expected cost category of a short number when dialled from a
    region (however, nothing is implied about its validity). If it is
    important that the number is valid, then its validity must first be
    checked using is_valid_short_number_for_region. Note that emergency
    numbers are always considered toll-free.

    Example usage:
    short_number = "110"
    region_code = "FR"
    if phonenumbers.is_valid_short_number_for_region(short_number, region_code):
        cost = phonenumbers.expected_cost(short_number, region_code)  # ShortNumberCost
        # Do something with the cost information here.

    Arguments:
    short_numobj -- the short number for which we want to know the expected cost category
              as a PhoneNumber object.
    region_dialing_from -- the region from which the number is dialed

    Return the expected cost category for that region of the short
    number. Returns UNKNOWN_COST if the number does not match a cost
    category. Note that an invalid number may match any cost category.

def expected_cost_for_region(short_numobj, region_dialing_from):
    """Gets the expected cost category of a short number when dialled from a
    region (however, nothing is implied about its validity). If it is
    important that the number is valid, then its validity must first be
    checked using is_valid_short_number_for_region. Note that emergency
    numbers are always considered toll-free.

    Example usage:
    short_number = "110"
    region_code = "FR"
    if phonenumbers.is_valid_short_number_for_region(short_number, region_code):
        cost = phonenumbers.expected_cost(short_number, region_code)  # ShortNumberCost
        # Do something with the cost information here.

    Arguments:
    short_numobj -- the short number for which we want to know the expected cost category
              as a PhoneNumber object.
    region_dialing_from -- the region from which the number is dialed

    Return the expected cost category for that region of the short
    number. Returns UNKNOWN_COST if the number does not match a cost
    category. Note that an invalid number may match any cost category.
    """
    if not _region_dialing_from_matches_number(short_numobj, region_dialing_from):
        return ShortNumberCost.UNKNOWN_COST
    # Note that region_dialing_from may be None, in which case metadata will also be None.
    metadata = PhoneMetadata.short_metadata_for_region(region_dialing_from)
    if metadata is None:  # pragma no cover
        return ShortNumberCost.UNKNOWN_COST
    short_number = national_significant_number(short_numobj)

    # The possible lengths are not present for a particular sub-type if they match the general
    # description; for this reason, we check the possible lengths against the general description
    # first to allow an early exit if possible.
    if not(len(short_number) in metadata.general_desc.possible_length):
        return ShortNumberCost.UNKNOWN_COST

    # The cost categories are tested in order of decreasing expense, since if
    # for some reason the patterns overlap the most expensive matching cost
    # category should be returned.
    if _matches_possible_number_and_national_number(short_number, metadata.premium_rate):
        return ShortNumberCost.PREMIUM_RATE
    if _matches_possible_number_and_national_number(short_number, metadata.standard_rate):
        return ShortNumberCost.STANDARD_RATE
    if _matches_possible_number_and_national_number(short_number, metadata.toll_free):
        return ShortNumberCost.TOLL_FREE
    if is_emergency_number(short_number, region_dialing_from):  # pragma no cover
        # Emergency numbers are implicitly toll-free.
        return ShortNumberCost.TOLL_FREE
    return ShortNumberCost.UNKNOWN_COST