Teeth Get Value By Index From List
Pull One Item Out of Any List (Negatives Welcome)
- input_list
- element
The instant a node hands you a LIST, you immediately want one item from it. The third prompt in that split list, the second tile from a grid split, the first image out of a batch. ComfyUI's built-in set has awkward ways to do this and no clean one, which is where Teeth Get Value By Index From List comes in: a list and an index in, one element out. It's Python's list[i] wearing a node costume, from the ComfyUI-Teeth utility pack.
How it works
The node is a one-liner dressed up with a lot of type handling. You feed it input_list (any list-like thing) and an index (integer, default 0, range −999,999 to 999,999 - so negative indexing works, -1 being the last element, just like Python). It then figures out what it's dealing with:
- A list of image tensors (say, from Teeth Split Grid Image) → returns the tensor at that index, ready to wire into a preview or sampler.
- A list of basic values (strings, ints, floats) → returns that value directly.
- Nested lists → it unwraps a layer and retries, recursing for deeply nested cases.
One element comes out the element output. INPUT_IS_LIST is on, which is what makes the "the whole thing is a list" framing work - ComfyUI delivers the entire list to one port and the node picks from it.
Inputs and outputs that matter
- input_list - the list. Must actually be a list or tuple; feed it a single tensor and it throws.
- index - which element. Default 0, negatives allowed.
- element (output) - the item at that index.
For a beginner, the only real decision is the index. 0-based, so the first item is 0, not 1.
Where people get burned
Out of range = dead run. index = 5 on a 3-item list raises an IndexError and kills the workflow, no graceful None. If your list length varies, guard it upstream or keep the index small.
It wants a list, not a tensor. Passing an image or mask tensor directly raises a TypeError telling you the input isn't a list or tuple. If you've got a batch tensor and want one image from it, you want an image-batch splitter, not this node.
The nested-list fallback is best-effort. It's the one fiddly corner of the code - for deeply nested structures it does a recursive retry, and if that fails it throws "Cannot handle elements of this type." In practice: feed it a flat list of tensors or strings and it never complains.
Install
ComfyUI Manager: search ComfyUI-Teeth. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/steelan9199/ComfyUI-Teeth
Restart. No extra dependencies, no model files - it's pure Python. One honest caveat about the pack: it's a small single-author project (GPL-3.0), the README is in Chinese, and there's no real community footprint behind it. For a node this simple that's fine; when the pack does have a rough edge, it's usually in the fancier nodes, not here.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| input_list | * | — | |
| index | INT | 0-999999–999999 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| element | * | — |