I want to pickle a file that sometime's is empty. Right now its empty, but my idea is that its going to grow over time.
How do i check if a file is "pickable" since it seems that you can not pickle a empty file?
I want to pickle a file that sometime's is empty. Right now its empty, but my idea is that its going to grow over time.
How do i check if a file is "pickable" since it seems that you can not pickle a empty file?
Pickle is considered unsafe. Try Cerealizer instead. It might incidentally solve your empty file problem.
Simply use a try/except block.
def example():
try:
return pickle.loads("")
except EOFError:
return None
It's easier to ask forgiveness than permission. :)