Comprehensive notes Creating Python Libraries Class 12 PDF

Creating Python Libraries Class 12 – In this chapter you will learn how to create and use a python library. This chapter is included in Computer Science Class 12 Syllabus 2021-22. So let’s begin!

If you want to read about the introduction to the python library follow this link.

Creating Python Libraries Class 12

Now let’s understand how to create python libraries. So when we talk about a python library, another related word is used with that, that word is Package. Sometimes library and package used interchangeably. So let us understand what is Package?

In the next section of creating python libraries class 12, we are going to discuss what is package. Here we go!

What is Python Package?

To understand what is a package you need to think about modules. A package is created with the set of modules under a common namespace on a single directory along with some special files.

The special files such as, which is an empty python module file stored in the directory structure. Your python library contains one or more packages including subpackages.

Let us understand the structure of the python package in the next section of creating python libraries class 12.

The structure of the Python Package

The structure of the python package consists of various modules and directories but not all folders having multiple modules are packages. You need must be a part of the folder, then only it can be considered as a package.

Observe this:

Python Package Directory Structure - Creating Python Libraries Class 12

Procedure for creating a Package

Follow these steps to create a Python Package:

  1. Decide the names for packages, folders and .py file (Don’t use any word separator except underscore)
  2. Create folders for your package and give them appropriate names
  3. Create file in packages and subfolders, if needed.
  4. Associate your files with python installation into site-packages folder, Check your installation path by following these steps
    1. you can check the path using import sys
    2. print(sys.path)
  5. Now copy your own package folder and paste it into python path (site packages)
  6. Now your package and modules are ready to use

Download creating python libraries PDF

Follow this link to download creating python libraries PDF:

Watch this video for practical explanation:

I hope you learn how to create a library and modules in python. If you have any queries or doubts regarding this article, Creating Python Libraries Class 12, feel free to ask in the comment section.

Thank you for reading this article.

Follow this link to get access of all contents for class 12 computer science notes.

Computer Science Class 12 Notes

Leave a Reply