[Python-ideas] Add a .pop() method to ZipFile

Andrew Barnert abarnert at yahoo.com
Fri May 10 17:53:03 CEST 2013


On May 10, 2013, at 6:22, Masklinn <masklinn at masklinn.net> wrote:

> Although technically it's only simple if you assume file content and
> central directory entries are in the same order, which is unwarranted.

Correct me if I'm wrong, but you can detect this case, and the case where there's a gap between the last file and the directory, and anything else that would break this code, just by parsing the directory, right?

> So, guessing it's because you can do a half-assed job at implementing
> pop(), it will usually work (and will silently corrupt your archive
> when it does not)

... but a version that had the checks would instead usually work, and raise an exception when it does not.

If I'm right, that's just a reason to fix the implementation, not to throw the idea out.

That being said, I'm still not sure what the benefit is. Sure, you could use a zipfile as a stack of temporary files or something, but it's still going to be slower than just a temp dir full of gzip files. Or you could destructively recursive-process a zipfile (reversed), but why? There must be a use case I'm missing that made the OP write this in the first place.


More information about the Python-ideas mailing list