Get By Index
Pull any element out of a list or batch without the errors
- py_list
- *
Get By Index returns one element from a list by position. You hand it a list and an index, and it hands back the item at that spot - an image, a string, a number, anything. It's the "grab the Nth thing" node you reach for when a loop has produced a list of results and you want, specifically, the third one.
It lives in the ovum/lists/python category of the comfy-ovum pack and describes itself as "Return an element of any type from a provided list/batch by index." The "any type" part is the point: because the input is typed *, this one node works on plain Python lists, on lists of images, on string lists, on anything that behaves like a sequence. No need for a separate node per data type.
Inputs and output
- py_list (
*) - the list (or batch) to pull from. The node is smart about unwrapping list-wrapped inputs, so it works whether the socket is feeding you a raw list or ComfyUI's wrapped flavor. - index (
INT, default0) - zero-based position. Set it as a widget or drive it from another node (a loop counter, for example).
Output: a single * socket carrying the element. Output is marked as an output node, so you can inspect the value directly in the UI.
Why you'd actually use it
- Picking from batch results. Run a batch, then grab one specific result for a preview or a follow-up step.
- Loop-aware indexing. Drive
indexfrom a loop's counter to walk through a list one element per iteration. - Building single values from lists. When a downstream node refuses a list and wants one concrete value, this is the extractor.
The display name is "Get by Index (List)" - don't be thrown by the parenthetical when you search; the class is GetByIndex.
Installing it
It ships in sfinktah/comfy-ovum:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
or search comfy-ovum in ComfyUI Manager, then restart. No models.
Where people get burned
The one real trap is out-of-range indexes. This node raises an IndexError if index is negative or beyond the end of the list - it does not return None and it does not wrap around. That's a deliberate design (contrast with Get Value from List, also in this pack, which returns None and logs a warning when out of bounds). So if your index is dynamic - a counter, a computed value - guard it, or use GetListLength first to know how big the list actually is. If you want the forgiving behavior, Get Value from List is the sibling to grab instead. Know which one you're using.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| py_list | * | — | |
| index | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |