A talk to be given at the Django and Python meetup on 1 Sep 2016
Python is inherently modular, i.e. even basic data types can be considered as objects. Modules extend this idea to allow a program to be thought of as a hierarchy of objects. From a software design point of view, entire Python programs can be turned into modules and be used as such, in whole or in part.
This talk will cover some basics about Python modules as well as the lessons learned from developing Shepherd, a modular tool for controlling a stable of hosts listed in an Ansible inventory file.
A basic knowledge of Python programming would be helpful in understanding this talk, but is not essential.
After viewing this talk, people should expect to be able to design (or rewrite!) their programs and libraries in a highly modular fashion, thereby making documentation, debugging and maintenance easier.
- Python version disclaimer
- import blah
- from fun import Ren, Stimpy
- Module Semantics
- Implicit namespaces
from __future__ import absolute_import1.
from . import helper1.
from .xyz import helper as xyz_helper
- Module contents
- The dir() Function
- Handles Dependencies and Versioning
1. Create with help of
setuptools1. Install locally using
- PyPI is the online archive, formerly known as cheeseshop
- Source Distributions
1. Create using
setuptools1. Install locally or elsewhere using
pip1. Publish to PyPI using
- Package files -- .whl
1. Create using
bdist_wheel1. Publish to PyPI using
- Error in import doesn't stop namespace creation
Alastair is a Software Engineer and system administrator by trade. He has a BSc in Computer Science from Curtin University.
His computer-related interests lie in various areas within his trade; suffice to say that he is a "geek of many colours". :) Alastair is a die-hard FOSS user and Linux fan.
He is also a freelancer with his own business. Warpspace IT is a consultancy with a fairly broad focus on the technical side of IT.