A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-February/138304.html below:

[Python-Dev] PEP 441 - Improving Python ZIP Application Support

[Python-Dev] PEP 441 - Improving Python ZIP Application Support [Python-Dev] PEP 441 - Improving Python ZIP Application SupportPaul Moore p.f.moore at gmail.com
Sun Feb 15 17:27:10 CET 2015
On 15 February 2015 at 16:00, Serhiy Storchaka <storchaka at gmail.com> wrote:
>> Would it be reasonable to add methods to the
>> ZipFile class to read and write the prefix data?
>
>
> But the stdlib zipfile module supports this.
>
> with open(filename, 'wb') as f:
>     f.write(shebang)
>     with zipfile.PyZipFile(f, 'a') as zf:

Good point.

It's not quite as easy to read the prefix data. I think you can do it
by reopening the file, and reading the bytes up to byte
min(i.header_offset for i in zf.infolist()). You need to reopen the
file, though, and that calculation doesn't work for an empty zipfile
(where you need to read to the start of the central directory
instead). But it's sort of possible, and it's a pretty specialised
requirement anyway (I only really needed it for testing).

Thanks,
Paul
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4