ComfyUI Node

pop

Pop items off a list like it's 1995

By StableLlama·Created about a year ago·Updated 4 days ago· 48
pop
  • list
  • list
  • item
index-1

Take something out, and keep the list that's left

pop is one of those Python verbs that every programmer just knows: it removes an item from a list and hands you that item at the same time. This node brings that to ComfyUI's LIST type (a real Python list passed around as one variable - not the native data list where items fan out individually). You'd use it when you're consuming a list one item at a time: pull a prompt out of a queue, pull a seed out of a batch, then feed whatever remains onward.

How it works

The node copies your input list, pops an item off the copy, and returns both pieces: the trimmed list and the removed item. Because it works on a copy, your original LIST is never mutated - which matters in ComfyUI, where the same LIST object can be wired into several places. If one branch popped in place, every branch would see a shorter list. It doesn't, so you're safe.

The index input is optional and defaults to -1, which means "last item" in Python's counting-from-the-end convention. Want the first item? Index 0. Want the second-from-last? -2. If the list is empty, you get None for the item instead of a crash - the author caught the IndexError.

Inputs and outputs

  • list (LIST) - what you're popping from.
  • index (INT, default -1) - the position to remove; negative counts from the end.

Outputs:

  • list (LIST) - the original minus the popped item.
  • item (*) - the thing you removed, ready to wire somewhere.

That item output is the whole point. Pop a filename off a list and feed it to a Load Image node. Pop a seed and hand it to a KSampler. The two outputs let you do "consume one, pass the rest" patterns that are awkward to build any other way in the graph.

Installing it

Part of the Basic data handling pack by StableLlama, the r/StableDiffusion regular whose model deep-dives (Flux Klein 9B, RealVisXL) are better-known than his code. This pack is pure lightweight Python: the pyproject declares zero runtime dependencies, no model downloads, no GPU usage.

Install through ComfyUI Manager (search "Basic data handling") or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart ComfyUI; the node lives under Basic/LIST.

Troubleshooting

Two gotchas. First, if you leave the index at -1 you always remove the last item - if you meant the first, set it to 0. Second, remember the item output is None for an empty list, so wire a check (the pack has comparison nodes) before feeding item downstream in a loop. And since this is LIST-only, a native ComfyUI data list won't plug into the input - convert it to a LIST first if you're mid-workflow.

CategoryBasic/LIST

Inputs (2)

NameTypeDefaultDescription
listLIST
indexoptINT-1

Outputs (2)

NameTypeDescription
listLIST
item*