{"id":27255,"library":"private-attribute-cpp","title":"private-attribute-cpp","description":"Provides a mechanism to define private attributes in C++ implementations exposed to Python via pybind11. Current version 1.4.11, released on PyPI. Development is active on GitHub.","status":"active","version":"1.4.11","language":"python","source_language":"en","source_url":"https://github.com/Locked-chess-official/private_attribute_cpp","tags":["cpp","pybind11","private-attributes"],"install":[{"cmd":"pip install private-attribute-cpp","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for C++/Python bindings.","package":"pybind11","optional":false}],"imports":[{"note":"The correct import path.","symbol":"PrivateAttribute","correct":"from private_attribute_cpp import PrivateAttribute"}],"quickstart":{"code":"from private_attribute_cpp import PrivateAttribute\n\n# Define a class with a private attribute\nclass MyClass:\n    def __init__(self):\n        self.__private_attr = PrivateAttribute('private_value')\n\n    def get_private_attr(self):\n        return self.__private_attr\n\nobj = MyClass()\nprint(obj.get_private_attr())  # Access via method","lang":"python","description":"Shows how to use PrivateAttribute to define a private attribute in a Python class."},"warnings":[{"fix":"Use Python name mangling (double underscore) for true Python-level privacy; rely on PrivateAttribute only for C++ integration.","message":"The 'PrivateAttribute' object itself does not enforce privacy at the Python level; it's a marker for C++ extensions. The privacy is only enforced when accessed from C++ code.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure pybind11 is installed: pip install pybind11","message":"If you import directly from 'private_attribute_cpp' without having pybind11 installed, you may get a cryptic error about missing shared library.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Reinstall the package: pip install --force-reinstall private-attribute-cpp","cause":"Missing or incorrect installation; the package may not have been built correctly.","error":"ImportError: cannot import name 'PrivateAttribute' from 'private_attribute_cpp'"},{"fix":"pip install pybind11","cause":"Pybind11 is a required dependency not installed.","error":"ModuleNotFoundError: No module named 'pybind11'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}