{"id":491,"date":"2025-05-19T11:36:32","date_gmt":"2025-05-19T11:36:32","guid":{"rendered":"https:\/\/buhave.com\/courses\/?p=491"},"modified":"2026-06-06T11:36:31","modified_gmt":"2026-06-06T11:36:31","slug":"modules-and-packages","status":"publish","type":"post","link":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/","title":{"rendered":"Modules and Packages"},"content":{"rendered":"<h2>Importing modules<\/h2>\n<p>In this lesson, you&#8217;ll learn how to import modules in Python, including importing entire modules, importing specific items, and using aliases. By the end, you\u2019ll be able to organize code more effectively across projects. If you\u2019re new to Python, you may want to start with <a href=\"https:\/\/buhave.com\/courses\/python\/introduction-to-python\/\" title=\"Introduction to Python\">Introduction to Python<\/a> to get up to speed.<\/p>\n<h3>What Is a Module?<\/h3>\n<p>A module is a file containing Python definitions and statements, such as functions, variables, and classes. Modules allow you to logically organize your Python code by grouping related functions, classes, and variables into separate files. This way, you can reuse code across multiple programs.<\/p>\n<p><strong>How to Import a Module<\/strong><\/p>\n<p>You can import a module in Python using the import statement. There are several ways to import modules, and each method allows you to control the namespace and access of the module\u2019s contents.<\/p>\n<h3>1. Basic Import<\/h3>\n<p>The simplest form is to import the entire module. This gives you access to all the functions, classes, and variables defined in the module, and you can reference them using the module name.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p style=\"text-align: center\"><em>import math<\/em><\/p>\n<p style=\"text-align: center\"><em>print(math.sqrt(16)) # 4.0<\/em><\/p>\n<ul>\n<li>math is a built-in module that provides mathematical functions.<\/li>\n<li>You access its sqrt() function by prefixing it with the module name (math).<\/li>\n<\/ul>\n<h3>2. Import Specific Functions or Variables<\/h3>\n<p>You can import specific functions, classes, or variables from a module, which allows you to avoid using the module name as a prefix.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p style=\"text-align: center\"><em>from math import sqrt<\/em><\/p>\n<p style=\"text-align: center\"><em>print(sqrt(16)) # 4.0<\/em><\/p>\n<ul>\n<li>Here, we import only the sqrt() function from the math module, so you don\u2019t need to prefix it with math.<\/li>\n<\/ul>\n<h3>3. Importing with Aliases<\/h3>\n<p>You can import a module or function with an alias (a shorter name) using the as keyword. This is helpful when the module name is long or when you want to avoid naming conflicts.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p style=\"text-align: center\"><em>import numpy as np<\/em><\/p>\n<p style=\"text-align: center\"><em>array = np.array([1, 2, 3])<\/em><br \/>\n<em>print(array) # [1 2 3]<\/em><\/p>\n<ul>\n<li>Here, numpy is imported as np to save typing and make the code more concise.<\/li>\n<\/ul>\n<h3>4. Import All (Not Recommended)<\/h3>\n<p>You can import everything from a module using the * syntax. However, this is generally discouraged because it can lead to name conflicts and make the code harder to understand.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p style=\"text-align: center\"><em>from math import *<\/em><\/p>\n<p style=\"text-align: center\"><em>print(sqrt(16)) # 4.0<\/em><\/p>\n<ul>\n<li>This imports everything from the math module, so you don\u2019t need to use math. as a prefix.<\/li>\n<li>Caution: This can overwrite any existing functions or variables in the namespace with the same name.<\/li>\n<\/ul>\n<h3>5. Importing from a Submodule<\/h3>\n<ul>\n<li>Sometimes, a module contains submodules or subpackages. You can import a submodule or a specific item from it.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<p style=\"text-align: center\"><em>from datetime import datetime<\/em><\/p>\n<p style=\"text-align: center\"><em>now = datetime.now()<\/em><br \/>\n<em>print(now)<\/em><\/p>\n<p>Here, datetime is a submodule of the datetime module. We import it directly.<\/p>\n<h3>Summary of Importing Modules<\/h3>\n<table style=\"border-collapse: collapse;width: 100%;font-family: Arial, sans-serif;margin: 15px 0\" border=\"1\" cellspacing=\"0\" cellpadding=\"8\">\n<thead>\n<tr>\n<th style=\"padding: 12px;text-align: left;border-bottom: 2px solid #000\"><strong>Syntax<\/strong><\/th>\n<th style=\"padding: 12px;text-align: left;border-bottom: 2px solid #000\"><strong>Description<\/strong><\/th>\n<th style=\"padding: 12px;text-align: left;border-bottom: 2px solid #000\"><strong>Example<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\"><code>import module_name<\/code><\/td>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\">Imports the entire module (access items with <code>module_name.item<\/code>)<\/td>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\"><code>import math<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\"><code>from module_name import item<\/code><\/td>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\">Imports specific items directly into current namespace<\/td>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\"><code>from math import sqrt<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\"><code>import module_name as alias<\/code><\/td>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\">Imports module with a shorter alias name<\/td>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\"><code>import numpy as np<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\"><code>from module_name import *<\/code><\/td>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\">Imports all items from module (can cause namespace pollution)<\/td>\n<td style=\"padding: 12px;border-bottom: 1px solid #000\"><code>from math import *<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 12px\"><code>from module_name.submodule import item<\/code><\/td>\n<td style=\"padding: 12px\">Imports specific item from a submodule<\/td>\n<td style=\"padding: 12px\"><code>from datetime import datetime<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Using external modules is common in real-world projects. To install and manage external libraries, you can use pip, and for more on integrating external libraries into your Python projects, see the <a href=\"https:\/\/buhave.com\/courses\/python\/working-with-external-libraries\/\" title=\"Working with External Libraries\">Working with External Libraries<\/a> course.<\/p>\n<p><strong>Using External Modules<\/strong><\/p>\n<p>In addition to the built-in modules like math, Python allows you to use third-party libraries. To use an external module, you often need to install it first, which can be done using pip (Python\u2019s package installer). For practical guidance on working with external libraries, consider the <a href=\"https:\/\/buhave.com\/courses\/python\/working-with-external-libraries\/\" title=\"Working with External Libraries\">Working with External Libraries<\/a> course.<\/p>\n<p><strong>For example:<\/strong><\/p>\n<p style=\"text-align: center\"><em>pip install requests<\/em><\/p>\n<p>Once installed, you can import it just like any other module:<\/p>\n<p style=\"text-align: center\"><em>import requests<\/em><\/p>\n<p style=\"text-align: center\"><em>response = requests.get(&#8220;https:\/\/www.example.com&#8221;)<\/em><br \/>\n<em>print(response.status_code)<\/em><\/p>\n<h2>Standard Library overview<\/h2>\n<p>The Python Standard Library is a collection of modules and packages that come bundled with Python. It provides a wide range of functionality, from basic data structures to advanced networking, file handling, and internet protocols. The Standard Library is one of Python&#8217;s most powerful features because it provides well-tested, robust tools for many common tasks, saving you from reinventing the wheel. If you\u2019re new, you might start with <a href=\"https:\/\/buhave.com\/courses\/python\/introduction-to-python\/\" title=\"Introduction to Python\">Introduction to Python<\/a> for a quick tour.<\/p>\n<p><strong>Here\u2019s an overview of the Python Standard Library:<\/strong><\/p>\n<h3>Key Categories of the Python Standard Library<\/h3>\n<p><strong>1. Text Processing<\/strong><\/p>\n<ul>\n<li>string: Contains common string operations and constants.<\/li>\n<li>re: Provides support for regular expressions.<\/li>\n<li>textwrap: Useful for formatting text for output (e.g., wrapping long lines).<\/li>\n<li>unicodedata: Provides access to the Unicode Character Database.<\/li>\n<\/ul>\n<p><strong>Example (Regular Expressions):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import re<\/em><br \/>\n<em>pattern = r&#8221;\\d+&#8221;<\/em><br \/>\n<em>text = &#8220;There are 123 apples&#8221;<\/em><br \/>\n<em>result = re.findall(pattern, text)<\/em><br \/>\n<em>print(result) # [&#8216;123&#8217;]<\/em><\/p>\n<p><strong>2. Data Serialization<\/strong><\/p>\n<ul>\n<li>json: Used for parsing and producing JSON (JavaScript Object Notation) data.<\/li>\n<li>csv: Helps with reading and writing CSV files.<\/li>\n<li>pickle: Allows Python objects to be serialized into a byte stream and vice versa.<\/li>\n<\/ul>\n<p><strong>Example (JSON):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import json<\/em><br \/>\n<em>data = {&#8220;name&#8221;: &#8220;Alice&#8221;, &#8220;age&#8221;: 30}<\/em><br \/>\n<em>json_string = json.dumps(data)<\/em><br \/>\n<em>print(json_string) # &#8216;{&#8220;name&#8221;: &#8220;Alice&#8221;, &#8220;age&#8221;: 30}&#8217;<\/em><\/p>\n<p><strong>3. File and Directory Access<\/strong><\/p>\n<ul>\n<li>os: Provides functions for interacting with the operating system, such as manipulating files and directories.<\/li>\n<li>shutil: Offers a higher-level interface for file operations, including copying and removing files.<\/li>\n<li>pathlib: A modern approach to handling file system paths.<\/li>\n<\/ul>\n<p><strong>Example (File Operations):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import os<\/em><br \/>\n<em>os.mkdir(&#8220;new_folder&#8221;) # Creates a new folder<\/em><\/p>\n<p><strong>4. Mathematics and Numbers<\/strong><\/p>\n<ul>\n<li>math: Contains mathematical functions, constants, and operations like trigonometry, logarithms, and square roots.<\/li>\n<li>decimal: Provides support for fast floating-point arithmetic with arbitrary precision.<\/li>\n<li>random: Useful for generating random numbers and performing random selections.<\/li>\n<\/ul>\n<p><strong>Example (Random Number):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import random<\/em><br \/>\n<em>print(random.randint(1, 10)) # Random number between 1 and 10<\/em><\/p>\n<p><strong>5. Internet and Networking<\/strong><\/p>\n<ul>\n<li>socket: Implements low-level networking interfaces, including client-server communication.<\/li>\n<li>http: Modules for working with HTTP, including http.client and http.server.<\/li>\n<li>email: Provides email handling functionalities like parsing and constructing email messages.<\/li>\n<\/ul>\n<p><strong>Example (Socket):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import socket<\/em><br \/>\n<em>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<\/em><br \/>\n<em>s.connect((&#8216;www.example.com&#8217;, 80))<\/em><\/p>\n<p><strong>6. Concurrency and Parallelism<\/strong><\/p>\n<ul>\n<li>threading: Provides a way to create and manage threads for concurrent execution.<\/li>\n<li>asyncio: Enables asynchronous programming for managing I\/O-bound tasks concurrently.<\/li>\n<li>multiprocessing: Allows parallel processing using multiple processes.<\/li>\n<\/ul>\n<p><strong>Example (Threading):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import threading<\/em><br \/>\n<em>def print_numbers():<\/em><br \/>\n<em>for i in range(5):<\/em><br \/>\n<em>print(i)<\/em><br \/>\n<em>thread = threading.Thread(target=print_numbers)<\/em><br \/>\n<em>thread.start()<\/em><\/p>\n<p><strong>7. System and OS Utilities<\/strong><\/p>\n<ul>\n<li>sys: Provides access to system-specific parameters and functions, such as reading command-line arguments.<\/li>\n<li>platform: Used to access the underlying platform (OS) information.<\/li>\n<li>time: Provides time-related functions, like measuring elapsed time and sleeping.<\/li>\n<\/ul>\n<p><strong>Example (System Info):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import sys<\/em><br \/>\n<em>print(sys.version) # Prints Python version<\/em><\/p>\n<p><strong>8. Functional Programming Tools<\/strong><\/p>\n<ul>\n<li>functools: Contains higher-order functions and tools for functional programming, such as reduce(), partial(), and memoization.<\/li>\n<li>itertools: Provides functions that work on iterators to produce complex iterators, such as combinations, permutations, and infinite sequences.<\/li>\n<\/ul>\n<p><strong>Example (Partial Function):<\/strong><\/p>\n<p style=\"text-align: center\"><em>from functools import partial<\/em><br \/>\n<em>def multiply(x, y):<\/em><br \/>\n<em>return x * y<\/em><br \/>\n<em>double = partial(multiply, 2)<\/em><br \/>\n<em>print(double(5)) # 10<\/em><\/p>\n<p><strong>9. Debugging and Testing<\/strong><\/p>\n<ul>\n<li>pdb: Python debugger for interactive debugging.<\/li>\n<li>unittest: Unit testing framework for writing and running tests.<\/li>\n<li>traceback: Provides utilities for extracting and formatting stack traces.<\/li>\n<\/ul>\n<p><strong>Example (Unittest):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import unittest<\/em><br \/>\n<em>class TestMath(unittest.TestCase):<\/em><br \/>\n<em>def test_addition(self):<\/em><br \/>\n<em>self.assertEqual(2 + 2, 4)<\/em><br \/>\n<em>unittest.main()<\/em><\/p>\n<p><strong>10. XML and Data Formats<\/strong><\/p>\n<ul>\n<li>xml.etree.ElementTree: Implements simple methods for parsing and creating XML data.<\/li>\n<li>csv: For reading and writing CSV files.<\/li>\n<li>configparser: Used for handling configuration files in .ini format.<\/li>\n<\/ul>\n<p><strong>Example (XML Parsing):<\/strong><\/p>\n<p style=\"text-align: center\"><em>import xml.etree.ElementTree as ET<\/em><br \/>\n<em>tree = ET.parse(&#8216;data.xml&#8217;)<\/em><br \/>\n<em>root = tree.getroot()<\/em><br \/>\n<em>print(root.tag) # Prints the root element&#8217;s tag<\/em><\/p>\n<p><strong>How to Access the Python Standard Library<\/strong><\/p>\n<p>Since the Standard Library is built into Python, you don\u2019t need to install anything additional to use it. You can simply import any module or package from it.<\/p>\n<p><strong>For example:<\/strong><\/p>\n<p style=\"text-align: center\"><em>import os # OS interface<\/em><br \/>\n<em>import math # Mathematical functions<\/em><br \/>\n<em>import random # Random number generation<\/em><\/p>\n<p>The modules in the Python Standard Library are extremely powerful and will cover most of your development needs, whether you are working on data processing, web development, automation, or testing.<\/p>\n<p><strong>Summary:<\/strong><\/p>\n<p><strong>The Python Standard Library is vast and provides modules for:<\/strong><\/p>\n<ul>\n<li>Text processing (e.g., string, re)<\/li>\n<li>Data serialization (e.g., json, csv)<\/li>\n<li>File and directory management (e.g., os, shutil)<\/li>\n<li>Mathematics (e.g., math, random)<\/li>\n<li>Internet and networking (e.g., socket, http)<\/li>\n<li>Concurrency (e.g., threading, asyncio)<\/li>\n<li>System utilities (e.g., sys, platform)<\/li>\n<li>Functional programming (e.g., functools, itertools)<\/li>\n<li>Debugging and testing (e.g., unittest, pdb)<\/li>\n<\/ul>\n<h2>Creating and using your own modules<\/h2>\n<p>Creating and using your own modules in Python allows you to organize and reuse code efficiently. It\u2019s one of the core principles of modular programming, where large programs are divided into smaller, manageable pieces. Let\u2019s go through the process step-by-step.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Importing modules In this lesson, you&#8217;ll learn how to import modules in Python, including importing entire modules, importing specific items, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":493,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[9],"tags":[],"class_list":["post-491","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Modules and Packages - Python Course<\/title>\n<meta name=\"description\" content=\"Modules and packages efficiently organize reusable, maintainable, and structured Python code into manageable, scalable components.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Modules and Packages - Python Course\" \/>\n<meta property=\"og:description\" content=\"Modules and packages efficiently organize reusable, maintainable, and structured Python code into manageable, scalable components.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/\" \/>\n<meta property=\"og:site_name\" content=\"BUHAVE\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BeYouHave\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/naveedsafdarawan\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-19T11:36:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-06T11:36:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Modules-and-Packages.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Naveed Safdar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Naveed Safdar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/\"},\"author\":{\"name\":\"Naveed Safdar\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\"},\"headline\":\"Modules and Packages\",\"datePublished\":\"2025-05-19T11:36:32+00:00\",\"dateModified\":\"2026-06-06T11:36:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/\"},\"wordCount\":1420,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Modules-and-Packages.webp\",\"articleSection\":[\"Python Course\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/\",\"name\":\"Modules and Packages - Python Course\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Modules-and-Packages.webp\",\"datePublished\":\"2025-05-19T11:36:32+00:00\",\"dateModified\":\"2026-06-06T11:36:31+00:00\",\"description\":\"Modules and packages efficiently organize reusable, maintainable, and structured Python code into manageable, scalable components.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/#primaryimage\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Modules-and-Packages.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Modules-and-Packages.webp\",\"width\":1200,\"height\":628,\"caption\":\"Modules and Packages\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/modules-and-packages\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Courses\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Course\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/learn\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Modules and Packages\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"name\":\"BUHAVE\",\"description\":\"Courses - Learn Online for Free\",\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/buhave.com\\\/courses\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\",\"name\":\"BUHAVE\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"width\":375,\"height\":75,\"caption\":\"BUHAVE\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/BeYouHave\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/buhave\",\"https:\\\/\\\/www.youtube.com\\\/@buhave\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\",\"name\":\"Naveed Safdar\",\"description\":\"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedsafdar\\\/\",\"https:\\\/\\\/www.facebook.com\\\/naveedsafdarawan\\\/\",\"https:\\\/\\\/www.youtube.com\\\/@naveedsafdar\"],\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/author\\\/naveed-safdar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Modules and Packages - Python Course","description":"Modules and packages efficiently organize reusable, maintainable, and structured Python code into manageable, scalable components.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/","og_locale":"en_US","og_type":"article","og_title":"Modules and Packages - Python Course","og_description":"Modules and packages efficiently organize reusable, maintainable, and structured Python code into manageable, scalable components.","og_url":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/","og_site_name":"BUHAVE","article_publisher":"https:\/\/www.facebook.com\/BeYouHave\/","article_author":"https:\/\/www.facebook.com\/naveedsafdarawan\/","article_published_time":"2025-05-19T11:36:32+00:00","article_modified_time":"2026-06-06T11:36:31+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Modules-and-Packages.webp","type":"image\/webp"}],"author":"Naveed Safdar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Naveed Safdar","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/#article","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/"},"author":{"name":"Naveed Safdar","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca"},"headline":"Modules and Packages","datePublished":"2025-05-19T11:36:32+00:00","dateModified":"2026-06-06T11:36:31+00:00","mainEntityOfPage":{"@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/"},"wordCount":1420,"commentCount":0,"publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"image":{"@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Modules-and-Packages.webp","articleSection":["Python Course"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/buhave.com\/courses\/python\/modules-and-packages\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/","url":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/","name":"Modules and Packages - Python Course","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/#website"},"primaryImageOfPage":{"@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/#primaryimage"},"image":{"@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Modules-and-Packages.webp","datePublished":"2025-05-19T11:36:32+00:00","dateModified":"2026-06-06T11:36:31+00:00","description":"Modules and packages efficiently organize reusable, maintainable, and structured Python code into manageable, scalable components.","breadcrumb":{"@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/buhave.com\/courses\/python\/modules-and-packages\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/#primaryimage","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Modules-and-Packages.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Modules-and-Packages.webp","width":1200,"height":628,"caption":"Modules and Packages"},{"@type":"BreadcrumbList","@id":"https:\/\/buhave.com\/courses\/python\/modules-and-packages\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Courses","item":"https:\/\/buhave.com\/courses\/"},{"@type":"ListItem","position":2,"name":"Python Course","item":"https:\/\/buhave.com\/courses\/learn\/python\/"},{"@type":"ListItem","position":3,"name":"Modules and Packages"}]},{"@type":"WebSite","@id":"https:\/\/buhave.com\/courses\/#website","url":"https:\/\/buhave.com\/courses\/","name":"BUHAVE","description":"Courses - Learn Online for Free","publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/buhave.com\/courses\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/buhave.com\/courses\/#organization","name":"BUHAVE","url":"https:\/\/buhave.com\/courses\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","width":375,"height":75,"caption":"BUHAVE"},"image":{"@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/BeYouHave\/","https:\/\/www.linkedin.com\/company\/buhave","https:\/\/www.youtube.com\/@buhave"]},{"@type":"Person","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca","name":"Naveed Safdar","description":"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.","sameAs":["https:\/\/www.linkedin.com\/in\/naveedsafdar\/","https:\/\/www.facebook.com\/naveedsafdarawan\/","https:\/\/www.youtube.com\/@naveedsafdar"],"url":"https:\/\/buhave.com\/courses\/author\/naveed-safdar\/"}]}},"_links":{"self":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/comments?post=491"}],"version-history":[{"count":4,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/491\/revisions"}],"predecessor-version":[{"id":1122,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/491\/revisions\/1122"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media\/493"}],"wp:attachment":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media?parent=491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/categories?post=491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/tags?post=491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}