ComfyUI Node

_.range

Generate a List of Integers Without Typing Them Out

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.range
  • py_list
  • LIST
start0
stop0
step1

_.range builds a list of integers for you. Set a start, a stop, and a step, and it returns the whole arithmetic progression as a LIST - 0,1,2,3,4,5, say. It's the "make me a sequence" node, and it's the natural way to drive batch operations or feed a list of indexes into a loop.

How it works

The semantics are Python's range through and through:

  • start is included, stop is excluded - range 0 to 5 gives [0, 1, 2, 3, 4], no five
  • step controls the increment; negative steps count down, so 5 down to 0 with step -1 gives [5, 4, 3, 2, 1]
  • If you leave start unset it defaults to 0; step defaults to 1

The exclusive stop is the thing that bites everyone at least once. If you want five values starting at 0, your stop is 5 - which feels like a fencepost error the first time you count the output and see four items.

The inputs:

  • py_list - the primary input (also accepts a _.CHAIN)
  • start - INT widget, default 0
  • stop - INT widget, default 0
  • step - INT widget, default 1

Output: a LIST of integers.

What you'd use it for

The obvious pattern is batch iteration: generate a range of indexes, then fan that list out into a repeat/loop structure or a batch-processing node that wants one value per pass. It's also handy for building test data or generating sequences of values to feed into a formatter. It's the "give me all the frame numbers" node for anything frame-indexed.

If you need something that ticks - outputs one value at a time and tells you when it's exhausted or wrapped - this same pack ships XRange, which is a friendlier choice for iterator-style use. _.range is for when you want the whole list materialized in one shot.

The family mechanics

Like the rest of the underscore nodes, the primary input accepts a _.CHAIN, and when it's a plain value the node deep-copies it, runs, and returns the finished list without touching your source.

Installing

Part of 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, no extra pip packages for the underscore nodes - the port is bundled in the repo.

The bottom line

The fastest way to materialize a sequence of integers in your graph. Just remember: stop is exclusive, and negative steps count down.

Categoryovum/underscore

Inputs (4)

NameTypeDefaultDescription
py_listopt*Primary input object (expected array). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining.
startoptINT0start (int)
stopoptINT0stop (int)
stepoptINT1step (int)

Outputs (1)

NameTypeDescription
LISTLIST