PyList: Get By Index
Read one value out of a PyList without touching List processing
- PYLIST
- *
This is the PyList version of List: Get By Index, and the distinction actually matters in this pack. If you've built up a PYLIST - say from Create PyList, Split String's PYLIST output, or Merge PyList - and you just want one item out of it as a plain value, this is the node. No List-processing, no per-item execution triggered anywhere, just Python-style indexing on a value that's sitting there as one array.
How it works
Same mechanics as its List sibling: connect a PYLIST, set an index, get the item back. Index 0 is the first item, -1 is the last, and negative indexing works the whole way down the array the way you'd expect from plain Python. The difference from List: Get By Index isn't the indexing logic - it's identical - it's the type of thing you're reading from. A PYLIST is a single bundled array value, not ComfyUI's native List-processing mechanism, so pulling one item out of it doesn't interact with per-item execution at all. You're just doing my_list[index] and getting a value back.
That matters because these two container types genuinely behave differently everywhere else in a graph. A List triggers downstream nodes to run once per item; a PyList is inert data that sits there until something explicitly unpacks it. If you connect this node's PYLIST input to something that's actually a List, ComfyUI's type system usually won't even let the wire form - which is your signal to convert first.
The inputs and outputs that matter
PYLIST- the raw Python list value to read from. Has to actually be aPYLIST-typed output; this node won't accept a List-processing value directly.index- position to read,0-based, with the same negative-indexing convention as the rest of the pack (-1= last item).
One output, typed *, carrying whatever value lived at that index. Wire it into whatever expects a single value of that type.
How to install it
Via ComfyUI Manager: search "ComfyUI-List-Utils", install, restart. Or clone it directly:
cd ComfyUI/custom_nodes
git clone https://github.com/godmt/ComfyUI-List-Utils.git
Restart after. Nothing to download, no dependencies beyond what ComfyUI already ships - it's index arithmetic on a Python list, about as simple as a custom node gets.
Common issues & troubleshooting
Out-of-range index doesn't error, it returns None. Same behavior as the List version, and it's the thing that actually bites people: an index past the end of the array (or before the start, going negative) doesn't throw, it silently hands you None. If a node further down the graph is complaining about a missing or wrong-type value and you can't figure out why, check this node's index against the actual length of your PYLIST first - a Get Length node dropped in temporarily will tell you the real size in one glance.
The socket won't connect to your List output. That's expected - this node wants a PYLIST, not a ComfyUI List. Run your List through List To PyList first if that's what you're working with, and the connection will accept it.
You need more than one item. For a subrange rather than a single value, use PyList: Slice instead, which returns a new PYLIST covering start:end rather than collapsing to one item.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| PYLIST | PYLIST | Connect a PyList, which is a raw Python list value. | |
| index | INT | 0-9007199254740992–9007199254740992 | Item index to read. 0 is the first item, -1 is the last item. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | The item at the selected index. Returns None when the index is out of range. |