fproperty
Project description
fproperty
- a simpler property decorator
Define the fget
/fset
/fdel
functions and return them:
from fproperty import fproperty
class Thing:
@fproperty
def my_attribute():
def fget(self):
return self._attr
def fset(self, value):
self._attr = value
def fdel(self):
del self._attr
return (fget, fset, fdel, "doc")
instead of property
chaining:
class Thing:
@property
def my_attribute(self):
return self._attr
@my_attribute.setter
def my_attribute(self, value):
self._attr = value
@my_attribute.deleter
def my_attribute(self):
del self._attr
which requires typing my_attribute
five times,
or by using the non-decorator case:
class Thing:
def fget(self):
return self._attr
def fset(self, value):
self._attr = value
def fdel(self):
del self._attr
my_attribute = property(fget, fset, fdel, "doc")
del fget, fset, fdel
which spreads out the definitions, and requires namespace cleanup.
Other examples
The fproperty
decorator can be returned a partial list:
@fproperty
def set_only_attribute():
def fset(self, value):
self._value = value
return (None, fset)
@property.apply
The property
builtin can be substituted, and has .apply
:
from fproperty import property
class Thing:
@property.apply
def attr():
def g(self): pass
return (g, )
Install
pip install fproperty
License
Licensed under the Apache License, Version 2.0 (the "License")
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
fproperty-0.2.0.zip
(5.3 kB
view details)
File details
Details for the file fproperty-0.2.0.zip
.
File metadata
- Download URL: fproperty-0.2.0.zip
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac3c8ac0546be90416b5de5e00b3247a6144e320d26081d5e37b2006ab177b48 |
|
MD5 | dc4d78b1ac271f369a6f0932a55ff29c |
|
BLAKE2b-256 | d1e1521a59b697916a8c2337668457e1eeb3dc5537ddea42d608cd77dd63c061 |