Graceful detection of EOF
adalke at mindspring.com
Fri Oct 8 00:24:51 CEST 2004
> How does one detect the EOF gracefully? Assuming I have a pickle file
> containing an unknown number of objects, how can I read (i.e.,
> pickle.load()) until the EOF is encountered without generating an EOF
Why isn't catching the exception graceful?
# UNTESTED CODE
for obj in load_pickle_iter(open("mydata.pickle", "rb")):
This is well in line with the normal Python idiom,
as compared to "look before you leap".
dalke at dalkescientific.com
More information about the Python-list