Raymond Hettinger wrote:
In the first case, you would write:
sets.extend(h.load(f))
yes, what I had was:
for s in iter(h.load(f)): sets.append(s)
...which I mistakenly thought was working, but in in fact boils down to
Raymond's code.
The problem is that each item that h.load(f) returns
> I dont know guppy,
> but if h.load(f) raises StopIteration upon eof, as seems implied by your
> proposal, then something like the following would work.
>
> sets.extend(h.load(f) for _ in xrange(1e9))
Sounds like hpy has a weird API. Either it should be an
iterator supporting __iter__() and nex
Sverker Nilsson wrote:
Sverker Nilsson wrote:
It reads one Stat object at a time and wants to report something
when there is no more to be read from the file.
Hmm, am I right in thinking the above can more nicely be written as:
>>> from guppy import hpy
>>> h = hpy()
>>> f = open(r'your.hp
A question arose on guppy-pe-list about how to iterate over objects
returned one by one by a method (load) called repeatedly. I defined a
generator to do this (loadall), but this seems unwieldy in general. Is
there a common idiom here that can usefully be encapsulated in a general
method?
On Mon,