Skip to main content
https://travis-ci.org/bast/somepackage.svg?branch=master https://img.shields.io/badge/license-%20MPL--v2.0-blue.svg

Somepackage

Show how to structure a Python project.

Inspired by https://github.com/kennethreitz/samplemod.

Recommendations

Python 2 or 3?

  • Develop your code under Python 3, test it for both Python 2 and Python 3 but consider Python 3 to be the default today.

Split your code into packages, modules, and functions

  • All code should be inside some function (except perhaps if __name__ == '__main__':).

  • Split long functions into smaller functions.

  • If you need to scroll through a function over several screens, it is probably too long.

  • Hide internals with underscores.

  • Organize related functions into modules.

  • If modules grow too large, split them.

  • Import from other modules under somepackage/ using from .somemodule import something.

  • Do file I/O on the “outside” of your code, not deep inside.

Naming

  • Give the subdirectory the same name as your package.

  • Before you name your package, check that the name is not taken on https://pypi.org (you may want to upload your package to PyPI one day).

Interfaces

  • In somepackage/__init__.py define what should be visible to the outside.

  • Use https://semver.org.

Testing

Dependency management

  • Package dependencies for developers should be listed in requirements.txt.

  • Package dependencies for users of your code (who will probably install via pip) should be listed in setup.py.

Code style

Share your package

Documentation

Suggestions? Corrections? Pull requests?

Yes please!

Metadata

Release files for somepackage 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for somepackage 1.2.3
File Size Uploaded
somepackage-1.2.3.tar.gz 8.6 kB Details

Release files / somepackage-1.2.3.tar.gz

Download URL somepackage-1.2.3.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
274f83dcf6110c8ecd21e7b8c9b2907274a1170830875738fda167e611143077
BLAKE2b-256 checksum
How to use checksums
81f6cdc617199548a495fd034a4128bb33b35857d2ddb97ddf25c4f29302569e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2.3 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page