Skip to main content

Show how to structure a Python project.

Project description

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.

  • Functions should do one thing and one thing only.

  • 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.

Classes vs. functions

  • Do not overuse classes.

  • Prefer immutable data structures.

  • Prefer pure functions.

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.

  • Alternatively, consider using http://pipenv.readthedocs.io.

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

Code style

Type checking

Share your package

Documentation

Suggestions? Corrections? Pull requests?

Yes please!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

window_blinds_rpi-0.0.9.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

window_blinds_rpi-0.0.9-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file window_blinds_rpi-0.0.9.tar.gz.

File metadata

  • Download URL: window_blinds_rpi-0.0.9.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3

File hashes

Hashes for window_blinds_rpi-0.0.9.tar.gz
Algorithm Hash digest
SHA256 b941845d25ea2df2dff7505510d54fa20a27fa139f1d6f4634e219cd30b213ed
MD5 98127bf582d7f6c266b48e4da1c32f52
BLAKE2b-256 c61e689a32008b56fec45c1b9e3d742845d2a1ea08a09c6cf5f233496ea7c5a7

See more details on using hashes here.

File details

Details for the file window_blinds_rpi-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: window_blinds_rpi-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3

File hashes

Hashes for window_blinds_rpi-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 03d690f26c8cc887da7c260c7efc18b6e0554d136caf9f0721107d08e70e8c9c
MD5 b49105e0d72c07e116c984fe654efc5c
BLAKE2b-256 569657f12e1a4f267a6fba05ca2b185349f8aa11767ebc6fcdfcc74bfc950f03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page