Message356537
Note that it is already possible, though awkward, to create cached properties dynamically. Using the example from PR GH-16838:
class ProcNet:
pass
for proto in ('icmp', 'icmp6', 'raw', 'raw6', 'tcp', 'tcp6', 'udp', 'udp6', 'udplite', 'udplite6'):
@cached_property
def prop(self, *, proto=proto):
with open(os.path.join("/proc/net", proto)) as file:
return file.read()
setattr(ProcNet, proto, prop)
prop.__set_name__(ProcNet, proto)
IMO this is good enough, considering that this is all pretty much required for dynamically creating normal (uncached) properties and other types of descriptors. |
|
Date |
User |
Action |
Args |
2019-11-13 16:03:01 | taleinat | set | recipients:
+ taleinat, carljm, sir-sigurd, Ricardo Branco |
2019-11-13 16:03:00 | taleinat | set | messageid: <1573660980.93.0.112251035636.issue38517@roundup.psfhosted.org> |
2019-11-13 16:03:00 | taleinat | link | issue38517 messages |
2019-11-13 16:03:00 | taleinat | create | |
|