Registry / type-stubs / private-attribute-cpp

private-attribute-cpp

JSON →
library1.4.11pypypiunverified

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.

pip install private-attribute-cpp
INSTALL
IMPORT
SIG · PRIVATE-ATTRIBUTE-
P
private-attribute-cpp
type-stubspythonv1.4.11
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PrivateAttribute
from private_attribute_cpp import PrivateAttribute
The correct import path.

Shows how to use PrivateAttribute to define a private attribute in a Python class.

from private_attribute_cpp import PrivateAttribute # Define a class with a private attribute class MyClass: def __init__(self): self.__private_attr = PrivateAttribute('private_value') def get_private_attr(self): return self.__private_attr obj = MyClass() print(obj.get_private_attr()) # Access via method
Debug
Known issues
gotchaThe '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.
fix
Use Python name mangling (double underscore) for true Python-level privacy; rely on PrivateAttribute only for C++ integration.
affects: all
gotchaIf you import directly from 'private_attribute_cpp' without having pybind11 installed, you may get a cryptic error about missing shared library.
fix
Ensure pybind11 is installed: pip install pybind11
affects: all
Upgrade
Version history
1.4.11latest on PyPI · released Apr 1, 2026
Audit
Dependencies
pybind11requiredRequired for C++/Python bindings.
Agent activity
24 hits · last 30 days
node
22
Amazon
1
OpenAI (training)
1
Resources