#NEWLINE# def _generate_prefixes( country_code , max_prefix_length , num_prefixes_per_size ) : #NEWLINE# #INDENT# def _generate_prefix( cc , existing_prefixes , i ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# prefix = ( existing_prefixes [ ( ( - 1 ) - i ) ] + str ( random . randint ( ( 0 if ( cc != 1 ) else 2 ) , 9 ) ) ) #NEWLINE# if ( prefix not in existing_prefixes ) : #NEWLINE# #INDENT# return prefix #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# prefixes = [ '' ] #NEWLINE# for _ in range ( max_prefix_length ) : #NEWLINE# #INDENT# for i in range ( num_prefixes_per_size ) : #NEWLINE# #INDENT# prefixes . append ( _generate_prefix ( country_code , country_code , i ) ) #NEWLINE# #UNINDENT# #UNINDENT# return prefixes