def __seqToRE(self, to_convert, directive):
        """Convert a list to a regex string for matching a directive.
        
        Want possible matching values to be from longest to shortest.  This
        prevents the possibility of a match occuring for a value that also
        a substring of a larger value that should have matched (e.g., 'abc'
        matching when 'abcdef' should have been the match).
        
        """
        for value in to_convert:
            if value != '':
                break
        else:
            return ''
        to_sort = [(len(item), item) for item in to_convert]
        to_sort.sort()
        to_sort.reverse()
        to_convert = [item for length, item in to_sort]
        regex = '|'.join(to_convert)
        regex = '(?P<%s>%s' % (directive, regex)
        return '%s)' % regex
Convert a list to a regex string for matching a directive.
        
        Want possible matching values to be from longest to shortest.  This
        prevents the possibility of a match occuring for a value that also
        a substring of a larger value that should have matched (e.g., 'abc'
        matching when 'abcdef' should have been the match).
        
        
recipes/Python/56036_Pure_Python_strptime/recipe-56036.py