{"id":19868171,"url":"https://github.com/hovey/pyschool","last_synced_at":"2026-04-29T19:34:37.459Z","repository":{"id":213614082,"uuid":"221724553","full_name":"hovey/pyschool","owner":"hovey","description":"Examples of Pythonic patterns","archived":false,"fork":false,"pushed_at":"2024-02-07T17:36:57.000Z","size":5761,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-11T18:16:00.404Z","etag":null,"topics":["matplotlib","patterns","principles","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hovey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-14T15:06:05.000Z","updated_at":"2024-06-01T02:42:30.000Z","dependencies_parsed_at":"2024-11-12T15:37:03.905Z","dependency_job_id":"66c5e647-707e-4ffe-a944-fb91c90e02a4","html_url":"https://github.com/hovey/pyschool","commit_stats":null,"previous_names":["hovey/pyschool"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hovey/pyschool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hovey%2Fpyschool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hovey%2Fpyschool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hovey%2Fpyschool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hovey%2Fpyschool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hovey","download_url":"https://codeload.github.com/hovey/pyschool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hovey%2Fpyschool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32441338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T18:12:22.909Z","status":"ssl_error","status_checked_at":"2026-04-29T18:11:33.322Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matplotlib","patterns","principles","python"],"created_at":"2024-11-12T15:32:39.083Z","updated_at":"2026-04-29T19:34:37.436Z","avatar_url":"https://github.com/hovey.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![black](https://github.com/hovey/pyschool/workflows/black/badge.svg)](https://github.com/hovey/pyschool/actions)\n[![coverage](https://github.com/hovey/pyschool/workflows/coverage/badge.svg)](https://github.com/hovey/pyschool/actions)\n[![codecov](https://codecov.io/gh/hovey/pyschool/branch/master/graph/badge.svg)](https://codecov.io/gh/hovey/pyschool)\n\n# pyschool\n\nThe **pyschool** repository demonstrates\n\n*Best Practices*, \n*Pythonic Practices*, and \n*Design Patterns* implemented in Python.\n\n## Best Practices\n\n* [D.R.Y. \u003e W.E.T.](doc/dry.md)\n* [Convention \u003e Configuration](doc/convention.md)\n* [Code Smell](doc/code_smell.md)\n* Verb Smell\n  * [Get and Set](doc/get_and_set.md)\n  * [C.R.U.D.](doc/crud.md)\n* [Client and Service](doc/client_service.md)\n* Production\n  * [Git Summary](doc/git_summary.md)\n  * Style (with Black)\n  * Test (with Pytest)\n  * [Coverage](doc/coverage.md)\n  * Continuous Integration (CI)\n  * Deployment (with PyPI)\n* Docstrings\n* Object Oriented Programming (OOP)\n  * Open-Closed Principle (OCP)\n  * Separation of concern\n  * Interface versus implementation\n* Singleton versus Collections, part of [REST](https://restfulapi.net/resource-naming/)\n* Test Driven Design (TDD) by Paul Everitt, 2020-06-10, [PyCharm Guide](https://www.jetbrains.com/pycharm/guide/tutorials/visual_pytest/background/)\n\n## Pythonic Practices\n\n* Iterator\n* Decorator (of Python)\n* List comprehension\n* Error handling\n\n## Patterns\n\n* Adapter\n* Singleton\n* Decorator\n* Factory\n  * Static Factory Method\n  * Builder\n  * Abstract Factory\n* Publish-Subscribe (aka \"PubSub\" and Observer)\n\n## Examples\n\n* Anatomy of a figure\n* Animation\n* Colors\n* Element scale versus density\n* Growth charts\n* Imports\n* Least squares\n* Midpoint differentiation\n* Oscillator\n* Quartiles\n* Scientific notation\n\n## Toolbox\n\n* VIM [macros](src/pyschool/vim_macros/example.py)\n\n## Pythonic Patterns\n\n### Attributes\n\n* See the [`get_set` example](src/pyschool/get_set/README.md), which goes through a short code example, with evolution from bad, to better, to best implementations.  \n\n### Client-Service\n\n* To come.\n\n### Decorators\n\n* An [example](src/pyschool/decorator/logging_decorator.py) of a logging decorator pattern, which can help D.R.Y. out code (based on [this example](http://book.pythontips.com/en/latest/decorators.html#logging)).\n* An [example](src/pyschool/decorator/decorators.py), using factorial, `tic-toc` timing convention, and [memoization](https://en.wikipedia.org/wiki/Memoization).\n* See also [Real Python](https://realpython.com/primer-on-python-decorators/), [Wiki Python](https://wiki.python.org/moin/PythonDecorators), [Yasoob Khalid](http://book.pythontips.com/en/latest/decorators.html)\n\n### Docstrings\n\n* See [Google docstring format](http://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)\n* Nice [examples](https://gist.github.com/candlewill/fce04bb26d402288cd02f09bd4f5f562) of Google docstring format\n\n### Error Checking (ask for forgiveness, not permission)\n\n* See [examples](src/pyschool/errors/error_check.md).\n\n### [Factory](src/pyschool/factory/README.md)\n\n### [Publish-Subscribe](src/pyschool/pubsub/README.md) (aka Observer)\n\n### Import\n\n* When [importing modules](src/pyschool/importable/importable.md) from non-local directories.  Used often in client-service patterns.\n\n### Inheritance\n\n* A compact [example](src/pyschool/inheritance_farm/readme.txt), showing a verb astraction (e.g., `speak`) and inheritance of behavior, with a simple client-service architecture.\n* [shapes](src/pyschool/super/shapes.py)\n\n### Model, View, Controller (MVC)\n\n* [shapes_mvc](src/pyschool/super/shapes_mvc.py)\n\n### Unit Test\n\n* An [example](tests/test_unittest.py), using the [unittest.mock](https://docs.python.org/3/library/unittest.mock.html#) library for testing in Python.\n* [Real Python](https://realpython.com/python-mock-library/) article.  \n\nExamples from `xyfigure_test.py`:\n\n```bash\n$ python xyfigure_test.py                      # for terse interaction,\n$ python -m unittest xyfigure_test             # for default interaction,\n$ python -m unittest -v xyfigure_test          # for higher verbosity, and\n\n$ python -m unittest xyfigure_test.TestImageDiff.test_same  # e.g., to test the test_same() method\n```\n\n## Examples\n\n### Conda\n\n* virual environment (venv)\n\n```bash\n# from [Apollo/sibl] with all folders containin __init__.py file:\n(base) conda create -n temp\n(base) conda activate temp\n(temp) conda install numpy scipy matplotlib\n(temp) conda install pip\n(temp) pip install -e .  # -e is development mode, if code updates, new pip install is not required\n(temp) conda list\n(temp) \n(temp) conda deactivate\n(base) conda remove -n temp --all\n# list all environments:\n(base) conda info --envs\n```\n\n* also, pip virtual environment (venv)\n\n```bash\n(base) python -m venv fire\n```\n\n### Computation\n\n* [Ordinary least squares](src/pyschool/least_squares/ols.py)\n* Several examples in the `monkey_see` folder  \n\n### Debugger\n\nExample:  From `~/sibl/xyfigure/test` in VS Code, `Run | Open Configurations` and add to `launch.json` the following:\n\n```json\n{\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"name\": \"Python: Current File\",\n            \"type\": \"python\",\n            \"request\": \"launch\",\n            \"program\": \"/Users/Apollo/sibl/xyfigure/xyfigure.py\",\n            \"args\": [\"signal_process_serialize.json\"],\n            \"console\": \"integratedTerminal\"\n        }\n    ]\n}\n```\n\n### Production\n\nOnce the code base has sufficient development, and it is ready for production, use the following steps:\n\n* TLC - timing, leaks, [coverage](https://github.com/marketplace/actions/coveralls-github-action)\n* Test\n  * Unit Test\n  * Integration Test\n* [Packaging/Distribution/PyPI](https://packaging.python.org/tutorials/packaging-projects/) (Build, Installer), and packaging [guide](https://packaging.python.org/guides/distributing-packages-using-setuptools/), and [distribution](https://pypi.org/) with PyPI.\n* [Packaging and Distribution](https://conda.io/projects/conda-build/en/latest/) with Conda to create a [Conda Package](https://conda.io/projects/conda/en/latest/user-guide/concepts/packages.html).  Building conda packages [from scratch](https://conda.io/projects/conda-build/en/latest/user-guide/tutorials/build-pkgs.html).\n* Client Use\n  * Client [Installation](https://packaging.python.org/tutorials/installing-packages/)\n  * Client Bug Reports (https://github.com/hovey/pyschool/issues)\n  \n  #### Production/Distribution Notes\n  \n```bash\n# -----------------\n# production server\n# -----------------\n$ cd ~/sibl/xyfigure\n$ rm -r xyfigure.egg-info/\n$ vim setup.py   # update setup.py, typically increment the version, located parent file README.md\n\n# update server if necessary\n$ python -m pip install --user --upgrade setuptools wheel\n$ python -m pip install --user --upgrade twine\n\n# build to the dist/ subdirectory\n$ python setup.py sdist bdist_wheel\n\n# assure the PyPI API token for the server is created on pypi.org and saved on the server at ~/.pypirc\n\n# remove any old .gz and .whl files in dist/ subdirectory\n$ cd dist/  #rm old .gz and old .whl\n$ cd ../  # back to the ~/sibl/xyfigure directory\n\n# deploy\n$ python -m twine upload dist/*\n\n# ------\n# client\n# ------\n$ pip list\n$ pip uninstall sibllib  # the old name\n$ cd /nscratch/chovey/casco_sim/temp/\n$ pip install --user xyfigure-0.0.4-py3-none-any.whl\n$ pip list\n```\n\n## References\n\n* [Effective-Python](https://hacktec.gitbooks.io/effective-python/content/en/Chapter1/Chapter1.html)\n* [GitHub build badge](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#adding-a-workflow-status-badge-to-your-repository)\n* [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)\n* [Example Google Style Python Docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhovey%2Fpyschool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhovey%2Fpyschool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhovey%2Fpyschool/lists"}