#NEWLINE# def arbitrary_phone_numbers_and_prefixes( country_code_and_prefixes ) : #NEWLINE# #INDENT# country_code_to_prefixes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( country_code , prefix ) in country_code_and_prefixes : #NEWLINE# #INDENT# if ( country_code not in country_code_to_prefixes ) : #NEWLINE# #INDENT# country_code_to_prefixes [ country_code ] = [ ] #NEWLINE# #UNINDENT# country_code_to_prefixes [ country_code ] . append ( prefix ) #NEWLINE# #UNINDENT# for ( country_code , prefix ) in country_code_and_prefixes : #NEWLINE# #INDENT# remainder_len = ( 10 - len ( prefix ) ) #NEWLINE# def _get_national_number( ) : #NEWLINE# #INDENT# return ( prefix + str ( random . randint ( ( ( 1 if prefix else 2 ) * ( 10 ** ( remainder_len - 1 ) ) ) , ( ( 10 ** remainder_len ) - 1 ) ) ) ) #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# national_number = _get_national_number ( ) #NEWLINE# if ( not any ( ( ( national_number . startswith ( another_prefix ) and another_prefix . startswith ( prefix ) ) for another_prefix in country_code_to_prefixes [ country_code ] if ( another_prefix and ( another_prefix != prefix ) ) ) ) ) : #NEWLINE# #INDENT# ( yield ( ( country_code + national_number ) , prefix ) ) #NEWLINE# break