This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author taleinat
Recipients Ricardo Branco, carljm, sir-sigurd, taleinat
Date 2019-11-13.16:03:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1573660980.93.0.112251035636.issue38517@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-11-13 16:03:01taleinatsetrecipients: + taleinat, carljm, sir-sigurd, Ricardo Branco
2019-11-13 16:03:00taleinatsetmessageid: <1573660980.93.0.112251035636.issue38517@roundup.psfhosted.org>
2019-11-13 16:03:00taleinatlinkissue38517 messages
2019-11-13 16:03:00taleinatcreate