IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
12.4.2 PyZipFile Objects


12.4.2 PyZipFile Objects

The PyZipFile constructor takes the same parameters as the ZipFile constructor. Instances have one method in addition to those of ZipFile objects.

writepy( pathname[, basename])
Search for files *.py and add the corresponding file to the archive. The corresponding file is a *.pyo file if available, else a *.pyc file, compiling if necessary. If the pathname is a file, the filename must end with .py, and just the (corresponding *.py[co]) file is added at the top level (no path information). If it is a directory, and the directory is not a package directory, then all the files *.py[co] are added at the top level. If the directory is a package directory, then all *.py[oc] are added under the package name as a file path, and if any subdirectories are package directories, all of these are added recursively. basename is intended for internal use only. The writepy() method makes archives with file names like this:

    string.pyc                                # Top level name 
    test/__init__.pyc                         # Package directory 
    test/testall.pyc                          # Module test.testall
    test/bogus/__init__.pyc                   # Subpackage directory 
    test/bogus/myfile.pyc                     # Submodule test.bogus.myfile

See About this document... for information on suggesting changes.