0% found this document useful (0 votes)
15 views2 pages

Packages in Python

Packages in Python are directories that contain multiple modules and must include an __init__.py file to be recognized by Python. A package can also contain sub-packages and modules, allowing for organized code structure. This chapter will cover how to bundle modules into a package, using examples such as a Game package.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Packages in Python

Packages in Python are directories that contain multiple modules and must include an __init__.py file to be recognized by Python. A package can also contain sub-packages and modules, allowing for organized code structure. This chapter will cover how to bundle modules into a package, using examples such as a Game package.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

PACKAGES IN PYTHON

We learned that modules are files containing Python statements and definitions, like function and
class definitions. We will learn in this chapter how to bundle multiple modules together to form a
package.

A package is basically a directory with Python files and a file with the name __init__.py. This
means that every directory inside of the Python path, which contains a file named __init__.py, will
be treated as a package by Python. It's possible to put several modules into a Package.

A package is a collection of python module. Module is a single python file


containing function definitions.

Similarly, as a directory can contain subdirectories and files, a Python package can have sub-
packages and modules.

A directory must contain a file named __init__.py in order for Python to consider it as a
package.

Example: consider the developing Game package


Steps to Create a Package:

You might also like