{"library":"public","title":"public: Python Module Visibility Decorator","description":"The `public` library for Python, version 2020.12.3, provides a `@public` decorator to explicitly mark functions, classes, and variables as part of a module's public API. It automatically manages and replaces the module's `__all__` list, aiming to simplify explicit module visibility control. The library appears to be in maintenance mode, with its last release in late 2020.","language":"python","status":"maintenance","last_verified":"Fri Apr 17","install":{"commands":["pip install public"],"cli":null},"imports":["from public import public"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"# my_module.py\nfrom public import public\n\n@public\ndef hello_world():\n    \"\"\"A publicly exposed function.\"\"\"\n    return \"Hello from the public module!\"\n\ndef _private_function():\n    \"\"\"A private function, not exposed.\"\"\"\n    return \"You shouldn't see this!\"\n\n@public(alias='my_custom_name')\ndef original_function_name():\n    \"\"\"A public function exposed under an alias.\"\"\"\n    return \"This function has a custom public name.\"\n\n# To use this module:\n# from my_module import hello_world, my_custom_name\n# print(hello_world())\n# print(my_custom_name())\n# try:\n#     from my_module import _private_function # This will raise an AttributeError\n# except AttributeError as e:\n#     print(f\"Error trying to import private function: {e}\")","lang":"python","description":"This example demonstrates how to use the `@public` decorator for functions and how to alias them. It also illustrates that non-decorated functions remain private and cannot be imported.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}