ComfyUI Node

pop

Pop one entry out — get the value AND the trimmed dict back

By StableLlama·Created about a year ago·Updated 4 days ago· 48
pop
  • input_dict
  • default_value
  • dict
  • value
key

"pop" removes one entry from a dictionary and returns two things: the value that was removed, and the dict with that entry gone. It's the pack's version of Python's dict.pop(), and the two outputs are the reason it exists - most removal nodes only give you back the modified dict. Pop gives you the value and the rest, so you can pull a field out, use it, and keep the trimmed dict all in one move.

The classic pattern: you have a config dict, one of its keys needs special handling (log it, transform it, send it somewhere), and you don't want that key continuing on with the dict. Pop extracts it and hands you the value to work with while the remaining dict goes on its way.

How it works

  • input_dict (DICT) - the dictionary to pop from.
  • key (STRING, default "") - which entry to remove.
  • default_value (*, optional) - the fallback if the key isn't found.
  • Output dict (DICT) - the dictionary with the entry removed.
  • Output value (*) - the removed value (or the default).

Two behaviors worth knowing precisely:

If the key is found, it's removed from a copy and you get the value back. Non-destructive to the input - the original dict is untouched, which matters in ComfyUI where one output feeds many consumers.

If the key is missing, you get the original dict back unchanged, and the value output is your default_value - or None if you didn't provide one. Note the node's description claims a missing key errors, but the actual code doesn't raise: it returns gracefully. Missing keys are a silent None, not a crash.

Gotchas

  • A missing key with no default silently yields None - if you later wire that value into something that expects a real value, you'll be debugging a phantom None. If missing keys are meaningful, always supply a default_value.
  • The key is a string widget, not a dropdown of the dict's keys. Misspell it and you get the default path, not an error.
  • You're removing by exact key name only - there's no "pop the last entry" mode here. For that, the pack's pop item/pop random nodes exist.

When to reach for it

Any time you need to both extract a value and slim down a dict for downstream. Pull the seed out of a settings dict to log it while the rest flows on; take a field you've consumed and keep it out of a save payload.

Install

Part of Basic data handling - pure Python, zero dependencies, no model downloads. ComfyUI Manager → search "Basic data handling", or:

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

then restart ComfyUI. It's the rare node that changes a dict and hands you the change - use the two outputs together and it's a genuinely useful move.

CategoryBasic/DICT

Inputs (3)

NameTypeDefaultDescription
input_dictDICT
keySTRING
default_valueopt*

Outputs (2)

NameTypeDescription
dictDICT
value*