def get_locale_identifier(tup, sep='_'):
 tup = tuple(tup[:4])
 (lang, territory, script, variant) = (tup + ((None,) * (4 - len(tup))))
 return sep.join(filter(None, (lang, script, territory, variant)))

def get_locale_identifier ( tup , sep = '_' ) : tup = tuple ( tup [ : 4 ] ) ( lang , territory , script , variant ) = ( tup + ( ( None , ) * ( 4 - len ( tup ) ) ) ) return sep . join ( filter ( None , ( lang , script , territory , variant ) ) )
the reverse of :func:parse_locale .