[Python-Dev] Add a -z interpreter flag to execute a zip file

Guido van Rossum guido at python.org
Mon Jul 23 19:34:33 CEST 2007


On 7/23/07, Crutcher Dunnavant <crutcher at gmail.com> wrote:
>
>
> Crutcher Dunnavant
>
> On Jul 23, 2007, at 9:55 AM, "Guido van Rossum" <guido at python.org>
> wrote:
>
> > On 7/12/07, Daniel Stutzbach <daniel at stutzbachenterprises.com> wrote:
> >> On 7/11/07, Andy C <andychup at gmail.com> wrote:
> >>> The good thing about this is that it's extremely simple -- basically
> >>> 20 lines of C code to add a -z flag that calls a 3-line Python
> >>> function in the runpy module.
> >>
> >> Instead of requiring a -z flag, why not have the interpreter peak at
> >> the file to see if it starts with one of the ZIP magic numbers?
> >>
> >> That way it Just Works.
> >
> > I guess you wouldn't recognize a zip file if it hits you in the face.
> > Literally. :-)
> >
> > Zip files don't start with a magic number.
>
> Don't they end with a sentinel? If so, what would be the difference?

There's an ambiguity -- a Zip file could start with a Python (or
shell, or Perl) script that bootstraps execution. This is used
regularly. Changing the semantics just because the file *ends* with
something funny sounds like asking for trouble.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list