Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Secret Recipes of the Python Ninja

You're reading from   Secret Recipes of the Python Ninja Over 70 recipes that uncover powerful programming tactics in Python

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788294874
Length 380 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Cody Jackson Cody Jackson
Author Profile Icon Cody Jackson
Cody Jackson
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Working with Python Modules FREE CHAPTER 2. Utilizing the Python Interpreter 3. Working with Decorators 4. Using Python Collections 5. Generators, Coroutines, and Parallel Processing 6. Working with Python's Math Module 7. Improving Python Performance with PyPy 8. Python Enhancement Proposals 9. Documenting with LyX 10. Other Books You May Enjoy

Introduction

Python modules are the highest-level components of Python programs. As suggested by their name, modules are modular, capable of being plugged in with other modules as part of an overall program to provide better separation of code while combining together to create a cohesive application.

Modules allow easy reuse of code, and provide separate namespaces to prevent variable shadowing between blocks of code. Variable shadowing involves having duplicate variables in different namespaces, possibly causing the interpreter to use an incorrect variable. Each Python file a developer creates is considered a separate module, allowing different files to be imported into a single, overall file that forms the final application.

Realistically, any Python file can be made a module by simply removing the .py extension; this is most commonly seen when importing libraries. Python packages are collections of modules; what makes a package special is the inclusion of an __init__.py file. We will cover the differences in detail later, so for now just recognize that there are several names for the same items.

You have been reading a chapter from
Secret Recipes of the Python Ninja
Published in: May 2018
Publisher: Packt
ISBN-13: 9781788294874
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image