Visit ComfyUI Online for ready-to-use ComfyUI environment
Converts Python literal strings to sequences for direct input in workflows, leveraging `ast.literal_eval` for safe evaluation.
The Literal
node is designed to convert a string representation of a Python literal into an actual sequence. This node is particularly useful when you need to input a sequence of values directly into your workflow without manually creating each element. By leveraging Python's ast.literal_eval
function, the Literal
node ensures that the input string is safely evaluated, allowing you to define complex sequences such as lists, tuples, dictionaries, and more. This capability can streamline your workflow by enabling the direct input of structured data, making it easier to manage and manipulate sequences within your AI art projects.
The literal
parameter is a string input that represents the Python literal you wish to convert into a sequence. This parameter supports multiline input, allowing you to define complex structures such as lists, tuples, and dictionaries. The function of this parameter is to provide a textual representation of the sequence you want to create. The default value is an empty string (''
), and there are no explicit minimum or maximum values, as it depends on the complexity of the Python literal you are defining. For example, you can input a list like "[1, 2, 3]"
or a dictionary like "{'key': 'value'}"
.
The sequence
output parameter is the result of evaluating the literal
input. It provides the actual sequence (e.g., list, tuple, dictionary) that was represented by the input string. This output is crucial for further processing within your workflow, as it allows you to work with structured data directly. The interpretation of this output depends on the input provided; for instance, if you input a list, the output will be a list, and if you input a dictionary, the output will be a dictionary.
literal
parameter to quickly input complex sequences without manually creating each element, saving time and reducing errors.ast.literal_eval
[]
), dictionaries in curly braces ({}
), and tuples in parentheses (()
).ast.literal_eval
cannot parse.© Copyright 2024 RunComfy. All Rights Reserved.