Pyobjects/List Insert
Drop an item into a list at a specific spot
- py_list
- item
- LIST
List Append always adds to the end. List Insert lets you choose where - Python's list.insert(index, item), as a node. Everything already at or after that position shifts over to make room.
What it does
Three required inputs: py_list (LIST), index (INT, default 0), and item (*, any type). The node inserts item into py_list at position index and returns the updated LIST. Because it's the standard Python insert() under the hood, it's forgiving about edge cases: an index beyond the list's length doesn't error, it just appends at the end; a very negative index inserts near the start rather than crashing. That's worth knowing if your index math is occasionally off by a bit - a slightly wrong index puts your item in the wrong place, it doesn't blow up the run.
Where it's actually handy: from the pack's own author - the point of chaining these list nodes is building up structured data inside the graph the way you would in a real script, without dropping to a Python node just to do it. Insert is for the cases where order matters and it's not simply "add to the end" - building a list where position 0 needs to always be a specific default, or reordering a small collection as it moves through a workflow.
The inputs and outputs that matter
py_list(required,LIST) - the list you're inserting into.index(required INT, default 0) - where the new item goes. Zero-based, like everywhere else in this pack.item(required, any type) - the value being inserted.- Output:
LIST- the list with the item inserted.
Installing it
The pack's the same everywhere you find it: ComfyUI Manager, search ComfyUI-LogicUtils, install, restart - or clone it yourself with cd ComfyUI/custom_nodes && git clone https://github.com/aria1th/ComfyUI-LogicUtils and restart. aria1th, the author, is also known as AngelBottomless - the trainer behind the Illustrious XL checkpoints most anime-SDXL finetunes descend from - but this repo is a small side project, not a heavyweight install. No models, essentially no dependencies; a Redditor comparing lightweight logic-node options for ComfyUI specifically landed on this pack because it doesn't drag anything else in. There's an opt-in install hook (COMFYUI_LOGICUTILS_AUTO_INSTALL=1) and a force-off flag (COMFYUI_LOGICUTILS_SKIP_INSTALL=1); with nothing heavy here, you probably won't need either.
Where people get burned
The main trap is assuming an out-of-range index will error the way List Get's does - it won't. Insert clamps rather than crashes, so if you're expecting a hard failure to catch a bug in your index calculation, you won't get one here; you'll just get a list with the item in an unexpected spot, and that can be a quieter, harder-to-spot bug than an outright crash. Log or preview the resulting list (a JSON Dump node downstream works well for this) if the exact position matters and you're not certain the index is right.
Second, don't confuse this with List Append when you don't actually care about position - Insert is one more input to wire (the index) for no benefit if "add to the end" is really all you need.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| py_list | LIST | — | |
| index | INT | 0 | — |
| item | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LIST | LIST | — |