@property with weakref
Project description
weakProperty
just a property, but it automatically got weakref
source code :
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
weakproperty-0.1.0.tar.gz
(2.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file weakproperty-0.1.0.tar.gz.
File metadata
- Download URL: weakproperty-0.1.0.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34e3c186d0e2e8aa9e881a7404b82cc99583891e2673049a099dbce9b66a7b03
|
|
| MD5 |
0ab2a8850318461c1de7c4f04081edc9
|
|
| BLAKE2b-256 |
fc2c769904d23b8c732e2ac2229c10baa431f7ba17ab2b41d213919dbd9cff81
|
File details
Details for the file weakproperty-0.1.0-py3-none-any.whl.
File metadata
- Download URL: weakproperty-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
926b5e8232d18b926275606dcc178d2db6d3fc21389cf7cb854ad518ff25b3c0
|
|
| MD5 |
fdbcd02887ba1fb1a906398630e4b322
|
|
| BLAKE2b-256 |
f2dce825ffe16f67b0982ade51b260a21b904eeedc54198610eaf7c18f471cbd
|