pyscripter / python4delphi

Free components that wrap up Python into Delphi and Lazarus (FPC)
MIT License
895 stars 307 forks source link

VarPyIterate raises EPyStopIteration exception with message 'Stop Iteration' #454

Closed nmadani closed 6 months ago

nmadani commented 6 months ago

Fantastic project!

In Webinar II's VarPythDemo, clicking Run raises an EPyStopIteration exception with the message 'Stop Iteration'.

Platforms: Python version: 3.12.1 (Windows 64, not ARM) Delphi 12 Athens Windows 11 Pro ARM 22H2 build 22621.2861 via Parallels Version 19.2.0 (54827) on macOS Sonoma 14.2.1

Thank you.

pyscripter commented 6 months ago

It does, but it gets handled. Just ignore it. This is standard and expected. StopIteration is raised by Python to exit for loops. See for instance https://stackoverflow.com/questions/14413969/why-does-next-raise-a-stopiteration-but-for-do-a-normal-return. and https://docs.python.org/3/library/exceptions.html.

nmadani commented 6 months ago

Thank you. Raising an exception for a normal condition, i.e., an end-of-loop condition signal for an iterator... well, that's a new pattern to me!