Developing Python Packages
James Fulton
Climate informatics researcher
You will build a full package, and cover:
Script - A Python file which is run like python myscript.py
Package - A directory full of Python code to be imported
numpySubpackage - A smaller package inside a package
numpy.random and numpy.linalgModule - A Python file inside a package which stores the package code.
Library - Either a package, or a collection of packages
math, os, datetime,...)Directory tree for simple package
mysimplepackage/
|-- simplemodule.py
|-- __init__.py
mysimplepackage, is a Python Packagesimplemodule.py contains all the package code__init__.py marks this directory as a Python package__init__.py
Empty file
simplemodule.py
def cool_function():
...
return cool_result
...
def another_cool_function():
...
return another_cool_result
File with generalized functions and code.
Directory tree for package with subpackages
mysklearn/
|-- __init__.py
|-- preprocessing
| |-- __init__.py
| |-- normalize.py
| |-- standardize.py
|-- regression
| |-- __init__.py
| |-- regression.py
|-- utils.py
Developing Python Packages