_.object
Turn Two Lists Into a Dictionary (or One List of Pairs)
- py_list
- values
- *
_.object is the dictionary builder of the underscore family. Give it a list of [key, value] pairs - or two parallel lists, one of keys and one of values - and it hands you a proper dict. If you've ever had a logic pack hand you keys and values as separate lists and wished they'd just become an object, this is the node.
How it works
The mechanism mirrors underscore.js: it zips the two inputs together into {key: value} pairs. Two ways to feed it:
- One list of pairs -
[["width", 1024], ["height", 576]]becomes{"width": 1024, "height": 576} - Two parallel lists - a list of keys plus a list of values in the
valuesinput
If duplicate keys show up, the last value wins, which is worth remembering if you're merging generated data and don't want silent surprises.
The inputs are:
py_list- the pairs list, or the keys listvalues- optional; the values list when you're going the two-list route
Output is a single DICT. Wire it into anything downstream that expects an object - metadata payloads, prompt builders, conditionals.
Where it sits in the family
It's the direct opposite of _.pairs (which flattens a dict back into [key, value] lists). Run _.pairs then _.object on the result and you get a round trip back to where you started, minus any ordering guarantees. This pairing is genuinely useful for building metadata objects to shove into save/export nodes, or for normalizing data that arrives in awkward shapes from different sources.
One caution: it expects list-ish input. I poked at the edge case of feeding it something that isn't a list and the port stumbles over itself rather than failing gracefully. Keep the inputs as lists or pairs and you'll be fine.
The chaining thing
Like every node in this family, py_list also accepts a _.CHAIN. Feed it a chain and _.object stays inside the chain (you unwrap with _.value at the end); feed it a plain value and the node deep-copies your input, builds the dict, and returns the finished result. Either way your upstream lists are never mutated.
Installing
Ships in comfy-ovum. ComfyUI Manager → search comfy-ovum → Install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart ComfyUI. No models to download, no extra pip packages for the underscore nodes - the underscore.js port is bundled in the repo, and the pack's heavier requirements are for its other nodes.
The bottom line
The fastest way to turn two parallel lists - or a list of pairs - into a real dictionary. Just feed it proper lists, and remember that on duplicate keys, the last one wins.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| py_listopt | * | Primary input object (expected array). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining. | |
| valuesopt | * | values: JSON allowed for arrays/objects where applicable. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |