Graceful detection of EOF
adalke at mindspring.com
Thu Oct 7 18:24:51 EDT 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