how to iterate python Iterable implementing objects, eg #S(PY::PYTHON-OBJECT :TYPE "<class 'generator'>" :HANDLE 5)
Opened this issue · 1 comments
vxe commented
equivalent in python:
for i in GENERATOR_OBJECT:
print(i['output'])
thanks in advance
digikar99 commented
You can repeatedly call the python's next
operator on the iterator/generator, until it raises a StopIteration error.
(defpackage :python-user
(:use :cl)
(:local-nicknames (:utils :alexandria)
(:py :py4cl)))
(in-package :python-user)
(let ((range (py:python-eval "iter(range(2))")))
(loop :for obj := (utils:ignore-some-conditions (py:python-error)
(py:python-call "next" range))
:while (print obj)))