I'm using the marshal library to unmarshal a file containing one or
more objects. The canonical way seems to be:
objs = []
while 1:
try:
objs.append(mar shal.load(fobj) )
except EOFError:
break
Maybe it's just me, but it seems as if this should be iterable. I can
get the behavior I want by writing:
def itermarshal(fob j):
while 1:
try:
yield marshal.load(fo bj)
except EOFError:
raise StopIteration
objs = [obj for obj in itermarshal(fob j)]
But it seems that this should be built-in somewhere. Given that the
marshal library has been around since roughly forever, is it just that
no one's bothered to add iteration support to it, or am I missing
something?
Thanks.
--
Tim Lesher
tl*****@gmail.c om