List Slicer
The list version of 'give me items 3 through 7'
- input_list
- list_slice
- count
Slicing is the operation people assume ComfyUI just has: "give me the first three items," "skip the first item," "take this range." It doesn't - you build it. List Slicer is that built-in, with start and end indices and a count so you know what you actually extracted. It's the list cousin of the pack's Image Batch Slicer, applied to any LIST.
It's part of DebugPadawan's ComfyUI Essentials, a small MIT-licensed utility pack with a full family of list nodes.
How it works
start is inclusive, end is exclusive - the standard Python convention. start = 2, end = 5 on a ten-item list gives you items 2, 3, and 4. Two behaviors are worth knowing exactly:
endis exclusive. Item at positionendis not included. The most common off-by-one in the whole pack.- "To the end" happens whenever
end <= start. The README's shorthand is "use 0 for to the end," but the code is broader: if your end index is at or below the start index, the node treats it as "give me everything from start onward." That meansend = 0works for to-the-end, and so does accidentally settingendbelowstart- you get a full tail slice instead of an error.
Inputs and outputs
- input_list - the LIST to slice.
- start - inclusive start index, default 0.
- end - exclusive end index, default 1.
end <= startmeans "to the end."
Outputs: list_slice (LIST) and count (INT - how many items you got).
Install
Standard custom-node fare:
cd ComfyUI/custom_nodes
git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials.git
Restart ComfyUI, or install via ComfyUI Manager by searching "DebugPadawan". requirements.txt lists numpy, torch, and opencv-python - numpy and torch already ship with ComfyUI and the shipped code never imports cv2, so no heavy downloads, no model files, no API keys.
Where people get burned
- The exclusive end.
start = 0, end = 3gives three items (0, 1, 2), not four. If your slice is always one short, this is why. - No negative start.
startis clamped to>= 0; if you wanted "everything except the last item," you can't sayend = -1- negative ends get treated as to-the-end too. Work around it by slicing a length, or use List Info'scountin a math node. - Silent to-the-end. Because any
end <= startmeans "rest of list," a buggy end value won't error - it'll just quietly give you the tail.
A typical pattern: slice off the first N items for one processing branch while the tail flows elsewhere, then check the count output to confirm you split where you thought you did.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input_list | LIST | — | |
| start | INT | 0 | — |
| end | INT | 1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| list_slice | LIST | — |
| count | INT | — |