Skip to content

overloading a cached_method in inherting/derived class #21281

@dkrenn

Description

@dkrenn
class P(object):
    @cached_method
    def blub(self):
        print('called P.blub')
        return 3

class Q(P):
    def blub(self):
        print('called Q.blub')
        super(Q, self).blub()
        return 7

p = P()
q = Q()
print p.blub()
print p.blub()
print '---'
print q.blub()
print q.blub()

results in

called P.blub
3
3
---
called Q.blub
called P.blub
7
3

The last line should clearly be the output 7 again (and not the 3 of the base class).

CC: @orlitzky

Component: misc

Issue created by migration from https://trac.sagemath.org/ticket/21281

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions