Opened 11 years ago

Last modified 10 years ago

#22691 closed New feature

Allow cached_property to be used on other methods — at Initial Version

Reported by: FunkyBob Owned by: nobody
Component: Utilities Version: dev
Severity: Normal Keywords:
Cc: loic84 Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This adds an optional name property to cached_property, overriding where it stores its cached value.

class Foo(object):
    def get_bar(self):
        ...heavy work...

    bar = cached_property(get_bar, name='bar')

Without the name, it would save the result in dictget_bar, thus masking the method.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top