(Jan-29-2024, 09:33 AM)Gribouillis Wrote:(Jan-29-2024, 09:18 AM)cametan Wrote: This means, since Python 3.11, some "change" in Python causes its strange behavior.
Could this be the cause of the new behavior?
What's new in Python 3.11 Wrote:The statistics functions mean(), variance() and stdev() now consume iterators in one pass rather than converting them to a list first. This is twice as fast and can save substantial memory. (Contributed by Raymond Hettinger in gh-90415.)See What's new in Python 3.11
Thanks. That could be the cause.
This seems a sort of pitfall. It might be safe to convert from the result of unfoldr to a list.
def baz(): from statistics import mean def foo(x): i = int(input()) return None if i == 0 else (i, x + 1) print(mean(list(unfoldr(foo, 0)))) # converting from unfold's iterable to list first, before passing it to statistics.meanAnyway, thanks for your advice!