{"id":16388146,"url":"https://github.com/kentonishi/pythonpp","last_synced_at":"2025-10-26T11:31:56.709Z","repository":{"id":57457392,"uuid":"270462638","full_name":"KentoNishi/PythonPP","owner":"KentoNishi","description":"[Python++] A robust Java-style OOP system for Python, with support for statics, encapsulation, and inheritance.","archived":false,"fork":false,"pushed_at":"2020-06-23T19:19:40.000Z","size":94,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T19:05:35.445Z","etag":null,"topics":["encapsulation","inheritance","oop","oop-principles","pypi-package","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pythonpp/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KentoNishi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-07T23:32:45.000Z","updated_at":"2024-05-15T22:23:50.000Z","dependencies_parsed_at":"2022-09-05T20:01:30.734Z","dependency_job_id":null,"html_url":"https://github.com/KentoNishi/PythonPP","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KentoNishi%2FPythonPP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KentoNishi%2FPythonPP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KentoNishi%2FPythonPP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KentoNishi%2FPythonPP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KentoNishi","download_url":"https://codeload.github.com/KentoNishi/PythonPP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238319561,"owners_count":19452359,"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":["encapsulation","inheritance","oop","oop-principles","pypi-package","python","python3"],"created_at":"2024-10-11T04:28:30.187Z","updated_at":"2025-10-26T11:31:51.431Z","avatar_url":"https://github.com/KentoNishi.png","language":"Python","readme":"# Python++\n\n![PyPI Deployment](https://github.com/KentoNishi/PythonPP/workflows/PyPI%20Deployment/badge.svg)\n![Unit Tests](https://github.com/KentoNishi/PythonPP/workflows/Unit%20Tests/badge.svg)\n\nA robust Java-style OOP system for Python, with support for statics, encapsulation, and inheritance.\n\n[View on PyPI](https://pypi.org/project/pythonpp/)\n/\nBuilt by\n[Kento Nishi](https://github.com/KentoNishi)\nand\n[Ronak Badhe](https://github.com/r2dev2bb8)\n\nPython++ allows Python programmers to use object oriented programming principles in Python.\n\n\n## Installation\nThe package is available on PyPI.\nYou can install the package with the following command:\n```shell\npip install pythonpp\n```\n\n## Usage\n\n### Importing the Library\nYou can import Python++ using a wildcard import statement.\n```python\nfrom pythonpp import *\n```\n\n### Class Declaration\nDeclare Python++ classes with the `@PythonPP` decorator.\n\n```python\n@PythonPP\nclass MyClass:\n    pass # class code here\n``` \n\n### Namespace and Scopes\nDeclare variables and methods for Python++ classes within `namespace`.\n\n```python\n@PythonPP\nclass MyClass:\n    def namespace(public, private):\n        pass # methods and variables here\n```\n\nCode within `namespace` has access to the following scopes:\n\n| Scope | Description |\n|:------|:------------|\n| `public` | The public instance scope. |\n| `private` | The private instance scope. |\n| `public.static` | The public static scope. |\n| `private.static` | The private static scope. |\n\n### Static Initializers\nDeclare static initializers for Python++ classes using the `@staticinit` decorator.\nStatic initializers do not have access to instance variables and methods.\nStatic initializers cannot have input parameters.\n\n```python\n@PythonPP\nclass MyClass:\n    def namespace(public, private):\n        @staticinit\n        def StaticInit():\n            public.static.publicStaticVar = \"Static variable (public)\"\n            private.static.privateStaticVar = \"Static variable (private)\"\n```\n\nAlternatively, static variables can be declared in the bare `namespace` **if the variable assignments are constant**. Using bare static variable declarations are **not recommended**.\n\n\n### Constructors\nConstructors can be declared using the `@constructor` decorator. Constructors can have input parameters.\n\n```python\n@PythonPP\nclass MyClass:\n    def namespace(public, private):\n        @constructor\n        def Constructor(someValue):\n            public.publicInstanceVar = \"Instance variable (public)\"\n            public.userDefinedValue = someValue\n```\n\n### Method Declarations\nMethods are declared using the `@method(scope)` decorator with the `public` and `private` scopes in `namespace`.\n\n```python\n@PythonPP\nclass MyClass:\n    def namespace(public, private):\n        @method(public)\n        def publicMethod():\n            pass # public instance method here\n        \n        @method(private)\n        def privateMethod():\n            pass # private instance method here\n        \n        @method(public.static)\n        def publicStaticMethod():\n            pass # public static method here\n        \n        @method(private.static)\n        def privateStaticMethod():\n            pass # private static method here\n```\n\n### Special Methods\nDeclare special built-in methods using the `@special` decorator.\n```python\n@PythonPP\nclass MyClass:\n    def namespace(public, private):\n        @special\n        def __str__():\n            return \"Some string value\"\n```\n\n### Inheritance\nClasses can extend other classes using standard Python class inheritance.\n```python\n@PythonPP\nclass ParentClass:\n    def namespace(public, private):\n        @staticinit\n        def StaticInit():\n            public.static.staticVar = \"Static variable\"\n\n        @constructor\n        def Constructor(param):\n            print(\"Parent constructor\")\n            public.param = param\n\n@PythonPP\nclass ChildClass(ParentClass): # ChildClass extends ParentClass\n    def namespace(public, private):\n        @staticinit\n        def StaticInit():\n            ParentClass.staticinit() # Call parent static initializer\n            public.static.staticVar2 = \"Static variable 2\"\n\n        @constructor\n        def Constructor(param):\n            # Call parent constructor\n            ParentClass.constructor(param)\n```\n\n## Quickstart Example\n```python\nfrom pythonpp import *\n\n@PythonPP\nclass ParentClass:\n    def namespace(public, private):\n        @staticinit\n        def StaticInit():\n            public.static.publicStaticVar = \"Public static variable\"\n            private.static.privateStaticVar = \"Private static variable\"\n\n        @constructor\n        def Constructor(parameter):\n            private.privateVariable = parameter\n\n@PythonPP\nclass ChildClass(ParentClass):\n    def namespace(public, private):\n        @staticinit\n        def StaticInit():\n            ParentClass.staticinit()\n\n        @constructor\n        def Constructor(parameter):\n            ParentClass.constructor(parameter)\n            public.publicVariable = \"Public variable\"\n            private.privateVariable = \"Private variable\"\n        \n        @method(public)\n        def getPrivateVariable():\n            return private.privateVariable\n        \n        @method(public.static)\n        def getPrivateStaticVar():\n            return private.static.privateStaticVar\n\n        @special\n        def __str__():\n            return \"ChildClass object\"\n```\n```python\nprint(ChildClass.publicStaticVar)\n# \u003e Private static variable\nprint(ChildClass.getPrivateStaticVar())\n# \u003e Private static variable\n\nobj = ChildClass(\"Parameter value\")\nprint(obj)\n# \u003e ChildClass object\nprint(obj.publicVariable)\n# \u003e Public variable\nprint(obj.getPrivateVariable())\n# \u003e Parameter value\ntry:\n    obj.privateVariable # results in an error\nexcept Exception as e:\n    print(e)\n# \u003e 'ChildClass' object has no attribute 'privateVariable'\n```\n\n## Full Example\nYou can view the full example Jupyter notebook [here](https://github.com/r2dev2bb8/PythonPP/blob/master/examples/example.ipynb).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentonishi%2Fpythonpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkentonishi%2Fpythonpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentonishi%2Fpythonpp/lists"}