プレイヤーズ・ハイ

 雑多な日記

2014 年 3 月 1 日の小ネタ

Python におけるモジュールとパッケージ その他の要素

  • module

    the basic unit of code reusability in Python: a block of code imported by some other code. Three types of modules concern us here: pure Python modules, extension modules, and

  • packages.

    pure Python module a module written in Python and contained in a single .py file (and possibly associated .pyc and/or .pyo files). Sometimes referred to as a ``pure module.''

  • extension module

    a module written in the low-level language of the Python implementation: C/C++ for Python, Java for Jython. Typically contained in a single dynamically loadable pre-compiled file, e.g. a shared object (.so) file for Python extensions on Unix, a DLL (given the .pyd extension) for Python extensions on Windows, or a Java class file for Jython extensions. (Note that currently, the Distutils only handles C/C++ extensions for Python.)

  • package

    a module that contains other modules; typically contained in a directory in the filesystem and distinguished from other directories by the presence of a file init.py.

  • root package

    the root of the hierarchy of packages. (This isn't really a package, since it doesn't have an init.py file. But we have to call it something.) The vast majority of the standard library is in the root package, as are many small, standalone third-party modules that don't belong to a larger module collection. Unlike regular packages, modules in the root package can be found in many directories: in fact, every directory listed in sys.path contributes modules to the root package.