(channel_names)
return ','.join([_f for _f in flattened_channel_list if _f]).strip()
Converts a list of channel names to a comma-delimited list of names.

    You can use this method to convert a list of physical or virtual channel
    names to a single string prior to using the DAQmx Create Channel methods or
    instantiating a DAQmx Task object.

    Args:
        channel_names (List[str]): The list of physical or virtual channel
            names.
    Returns:
        str:
        
        The resulting comma-delimited list of physical or virtual channel
        names.
Converts a list of channel names to a comma-delimited list of names.
Converts a list of channel names to a comma - delimited list of names .
def flatten_channel_string(channel_names):
    """
    Converts a list of channel names to a comma-delimited list of names.

    You can use this method to convert a list of physical or virtual channel
    names to a single string prior to using the DAQmx Create Channel methods or
    instantiating a DAQmx Task object.

    Args:
        channel_names (List[str]): The list of physical or virtual channel
            names.
    Returns:
        str:
        
        The resulting comma-delimited list of physical or virtual channel
        names.
    """
    unflattened_channel_names = []
    for channel_name in channel_names:
        unflattened_channel_names.extend(unflatten_channel_string(channel_name))

    # Go through the channel names and flatten them.
    flattened_channel_list = []
    previous = {
        'base_name': '',
        'start_index': -1,
        'end_index': -1
        }
    for channel_name in unflattened_channel_names:
        m = re.search('(.*[^0-9])?([0-9]+)$', channel_name)
        if not m:
            # If the channel name doesn't end in a valid number, just use the
            # channel name as-is.
            flattened_channel_list.append(
                _channel_info_to_flattened_name(previous))
            previous = {
                'base_name': channel_name,
                'start_index': -1,
                'end_index': -1
                }
        else:
            # If the channel name ends in a valid number, we may need to flatten
            # this channel with subsequent channels in the x:y format.
            current_base_name = m.group(1)
            current_index = int(m.group(2))

            if current_base_name == previous['base_name'] and (
                (current_index == previous['end_index'] + 1 and
                 previous['end_index'] >= previous['start_index']) or
                (current_index == previous['end_index'] - 1 and
                 previous['end_index'] <= previous['start_index'])):
                # If the current channel name has the same base name as the
                # previous and it's end index differs by 1, change the end
                # index value. It gets flattened later.
                previous['end_index'] = current_index
            else:
                # If the current channel name has the same base name as the
                # previous or it's end index differs by more than 1, it doesn't
                # get flattened with the previous channel.
                flattened_channel_list.append(
                    _channel_info_to_flattened_name(previous))
                previous = {
                    'base_name': current_base_name,
                    'start_index': current_index,
                    'end_index': current_index
                    }

    # Convert the final channel dictionary to a flattened string
    flattened_channel_list.append(
        _channel_info_to_flattened_name(previous))

    # Remove empty strings in list, convert to comma-delimited string, then trim
    # whitespace.
    return ','.join([_f for _f in flattened_channel_list if _f]).strip()
def flatten_channel_string ( channel_names ) : unflattened_channel_names = [ ] for channel_name in channel_names : unflattened_channel_names . extend ( unflatten_channel_string ( channel_name ) ) # Go through the channel names and flatten them. flattened_channel_list = [ ] previous = { 'base_name' : '' , 'start_index' : - 1 , 'end_index' : - 1 } for channel_name in unflattened_channel_names : m = re . search ( '(.*[^0-9])?([0-9]+)$' , channel_name ) if not m : # If the channel name doesn't end in a valid number, just use the # channel name as-is. flattened_channel_list . append ( _channel_info_to_flattened_name ( previous ) ) previous = { 'base_name' : channel_name , 'start_index' : - 1 , 'end_index' : - 1 } else : # If the channel name ends in a valid number, we may need to flatten # this channel with subsequent channels in the x:y format. current_base_name = m . group ( 1 ) current_index = int ( m . group ( 2 ) ) if current_base_name == previous [ 'base_name' ] and ( ( current_index == previous [ 'end_index' ] + 1 and previous [ 'end_index' ] >= previous [ 'start_index' ] ) or ( current_index == previous [ 'end_index' ] - 1 and previous [ 'end_index' ] <= previous [ 'start_index' ] ) ) : # If the current channel name has the same base name as the # previous and it's end index differs by 1, change the end # index value. It gets flattened later. previous [ 'end_index' ] = current_index else : # If the current channel name has the same base name as the # previous or it's end index differs by more than 1, it doesn't # get flattened with the previous channel. flattened_channel_list . append ( _channel_info_to_flattened_name ( previous ) ) previous = { 'base_name' : current_base_name , 'start_index' : current_index , 'end_index' : current_index } # Convert the final channel dictionary to a flattened string flattened_channel_list . append ( _channel_info_to_flattened_name ( previous ) ) # Remove empty strings in list, convert to comma-delimited string, then trim # whitespace. return ',' . join ( [ _f for _f in flattened_channel_list if _f ] ) . strip ( )