Nodes/ComfyUI-LogicUtils/Pyobjects/List Remove
ComfyUI Node

Pyobjects/List Remove

Delete an item by value, not position

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Pyobjects/List Remove
  • py_list
  • item
  • LIST

List Pop removes by position. List Remove removes by value - Python's list.remove(item), as a node. You tell it what to get rid of, not where it lives, and it finds the first match and takes it out.

What it does

Two required inputs: py_list (LIST) and item (*, any type - whatever value you want gone). The node scans the list for the first element equal to item, removes it, and returns the updated LIST. That "first match" detail matters: if your list has duplicates, only one copy goes, not all of them. If you need every occurrence gone, you'd need to loop this node (or filter the list some other way) rather than expecting one call to clear them all.

This is the node you reach for when you know what you want out of a list but not necessarily where it is - dropping a specific filename from a collected list, removing a value that turned out to be invalid, that kind of cleanup. Compare that to List Pop, which is for when you know the position (or just want "the last one"), and List Get, which only reads without modifying anything.

The inputs and outputs that matter

  • py_list (required, LIST) - the list to remove from.
  • item (required, any type) - the value to find and remove. Has to match exactly (Python equality) - a string "5" won't match the integer 5.
  • Output: LIST - the list with the first matching item taken out.

Installing it

Same as the rest of the pack: search ComfyUI-LogicUtils in ComfyUI Manager, install, restart. Or manually: cd ComfyUI/custom_nodes && git clone https://github.com/aria1th/ComfyUI-LogicUtils, then restart ComfyUI. Nothing to download beyond the code - no models, no meaningful dependency chain, which lines up with the pack getting recommended on Reddit specifically as the lightest option for basic list and logic operations, in a thread where heavier packs got ruled out for exactly the opposite reason. There's an opt-in install hook (COMFYUI_LOGICUTILS_AUTO_INSTALL=1) and a way to disable it outright (COMFYUI_LOGICUTILS_SKIP_INSTALL=1), though with essentially nothing heavy in this repo you're unlikely to ever need to touch either.

Where people get burned

The one that catches people: trying to remove an item that isn't actually in the list. Python's list.remove() raises a ValueError if the value isn't found - it doesn't silently no-op - so this node fails the run rather than passing the list through unchanged. If there's any chance the item might not be present (a conditional cleanup step, say), that's worth checking for before this node rather than after.

The other one is the equality trap: Python's == is exact by type as well as value, so "5" (a string) and 5 (an int) are not the same item as far as remove() is concerned, even though they look identical in a preview widget. If a removal isn't taking effect and the value looks right at a glance, double-check that the type matches too - a JSON Parse output that came through as a string when you expected a number is a common way this happens. As always with this pack, the README's own line about documentation still being written ("there are too many nodes") means the source is the fallback reference for anything not covered by the schema.

CategoryData

Inputs (2)

NameTypeDefaultDescription
py_listLIST
item*

Outputs (1)

NameTypeDescription
LISTLIST