Power Puter: Allow lists and tuples to be used as iters within list comprehension

This commit is contained in:
rgthree
2025-05-29 00:26:42 -04:00
parent 6096e515f2
commit b775441a4c
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -326,11 +326,11 @@ class _Puter:
raise
return val
if isinstance(stmt, ast.List):
if isinstance(stmt, (ast.List, ast.Tuple)):
value = []
for elt in stmt.elts:
value.append(self._eval_statement(elt, ctx=ctx))
return value
return tuple(value) if isinstance(stmt, ast.Tuple) else value
# f-strings: https://www.basicexamples.com/example/python/ast-JoinedStr
# Note, this will str() all evaluated items in the fstrings, and doesn't handle f-string
@@ -372,7 +372,7 @@ class _Puter:
# A call, like my_dct.items(), or a named ctx list
if isinstance(gen.iter, ast.Call):
gen_iters = self._eval_statement(gen.iter, ctx=gen_ctx)
elif isinstance(gen.iter, (ast.Name, ast.Attribute)):
elif isinstance(gen.iter, (ast.Name, ast.Attribute, ast.List, ast.Tuple)):
gen_iters = self._eval_statement(gen.iter, ctx=gen_ctx)
for gen_iter in gen_iters:
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "rgthree-comfy"
description = "Making ComfyUI more comfortable."
version = "1.0.2505272100"
version = "1.0.2505290026"
license = { file = "LICENSE" }
dependencies = []