micropython

Annotated tests/reference/methods.py

579:9df30d738ec1
2012-07-07 Paul Boddie Filter out __init__.py files when looking for submodule files.
paul@87 1
#!/usr/bin/env python
paul@87 2
paul@87 3
class B:
paul@87 4
    def f(self):
paul@186 5
        print self
paul@87 6
paul@186 7
def f(self):
paul@186 8
    print self
paul@87 9
paul@187 10
class A:
paul@187 11
    f0 = f
paul@187 12
paul@87 13
b = B()
paul@87 14
paul@186 15
            # on A      on a        context on A attribute  context on a attribute
paul@187 16
A.f0        # unbound   bound (a)   A (need A instance)     a
paul@187 17
A.f1 = f    # unbound   bound (a)   A (need A instance)     a
paul@186 18
A.f2 = B.f  # unbound   unbound     B (need B instance)     B (need B instance)
paul@186 19
A.f3 = b.f  # bound (b) bound (b)   b                       b
paul@87 20
a = A()
paul@186 21
a.f4 = f    # N/A       function    N/A                     none
paul@186 22
a.f5 = B.f  # N/A       unbound     N/A                     B (need B instance)
paul@186 23
a.f6 = b.f  # N/A       bound (b)   N/A                     b
paul@87 24
paul@87 25
# vim: tabstop=4 expandtab shiftwidth=4