Metadata-Version: 2.4
Name: weakProperty
Version: 0.1.0
Summary: @property with weakref
Author-email: howShouldIChooseMyUsername <trademark2179@gmail.com>
License: MIT
Keywords: weakref,property
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# weakProperty

just a property, but it automatically got weakref

source code :
```python
def weakProperty(func):
    attr_name = f"_weak_{func.__name__}"
    @property
    def wrapper(self):
        ref = getattr(self, attr_name, None)
        return None if ref is None else ref()

    @wrapper.setter
    def wrapper(self, value):
        if value is None:
            setattr(self, attr_name, None)
        else:
            setattr(self, attr_name, weakref.ref(value))

    @wrapper.deleter
    def wrapper(self):
        setattr(self, attr_name, None)

    return wrapper
```
## usage
same as `@property`
