{"id":16220716,"url":"https://github.com/elc/python-design-patterns","last_synced_at":"2025-04-10T16:06:48.938Z","repository":{"id":98145234,"uuid":"481798626","full_name":"ELC/python-design-patterns","owner":"ELC","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-19T14:51:54.000Z","size":123,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T13:51:19.984Z","etag":null,"topics":[],"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/ELC.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":"2022-04-15T01:23:37.000Z","updated_at":"2023-09-18T03:57:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"14f92677-12d0-4b2a-802c-c04be454905f","html_url":"https://github.com/ELC/python-design-patterns","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ELC%2Fpython-design-patterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ELC%2Fpython-design-patterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ELC%2Fpython-design-patterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ELC%2Fpython-design-patterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ELC","download_url":"https://codeload.github.com/ELC/python-design-patterns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248250743,"owners_count":21072682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-10T11:59:24.670Z","updated_at":"2025-04-10T16:06:48.922Z","avatar_url":"https://github.com/ELC.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Design Patterns\n\nThis repo is a collection of non-trivial examples of several design patterns\nimplemented in different ways. Its aim is to contrast *traditional* (i.e. GoF)\ndesign patterns with more Pythonic equivalents, metrics about each\nimplementation are also provided.\n\nThe notion of being Pythonic is indeed subjective and it is used in the sense\nof leveraging built-in Python features such as Protocols, Callable classes,\nclosures, partial evaluation, generators, decorators, first-class functions and\nso on.\n\nEach pattern has an independent README linked below with a guide to highlight\ndifferences between implementation details.\n\n## Why This repo?\n\nThe [python-patterns repo](https://github.com/faif/python-patterns) already\nprovides a succint and clear way to implement idiomatic patterns in Python.\n\nThis repo focuses on showing different ways to implement the same pattern,\nincluding the traditional Java/C/C# like implementation to provide the reader\nwith a comparison. Moreover metrics are added to each implementation to better\ncontrast solutions.\n\n## Patterns\n\n### Behavioural\n\n- [Strategy](./patterns/behavioural/strategy/README.md)\n- [Observer](./patterns/behavioural/observer/README.md)\n- [Iterator](./patterns/behavioural/iterator/README.md)\n- [Command](./patterns/behavioural/command/README.md)\n\n### Creational\n\n### Structural\n\n- [Bridge](./patterns/structural/bridge/README.md)\n\n## Metrics\n\nThe metrics to be used are:\n\n- Cyclomatic Complexity: is equal to the number of linearly independent paths through the code.\n- Maintainability Index: is calculated as a factored formula consisting of SLOC, Cyclomatic Complexity and Halstead volume.\n- LOC: The total number of lines of code. It does not necessarily correspond to the number of lines in the file.\n- LLOC: The number of logical lines of code. Every logical line of code contains exactly one statement.\n- SLOC: The number of source lines of code - not necessarily corresponding to the LLOC.\n\nTo generate the metrics, use the following commands from the [radon library](https://pypi.org/project/radon/):\n\n```\npython -m radon raw . -s -O stats.md\npython -m radon mi . -s -j -O mi.json\npython -m radon cc . -s --show-closures --total-average --md -O complexity.md\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felc%2Fpython-design-patterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felc%2Fpython-design-patterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felc%2Fpython-design-patterns/lists"}