getattr3call.pyx 468 Bytes
Newer Older
1
__doc__ = u"""
Stefan Behnel's avatar
Stefan Behnel committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
    >>> class test(object): a = 1
    >>> t = test()

    >>> f(t, 'a')
    1
    >>> f(t, 'b')
    Traceback (most recent call last):
    AttributeError: 'test' object has no attribute 'b'

    >>> g(t, 'a', 2)
    1
    >>> g(t, 'b', 2)
    2
"""

BROKEN = """
    >>> h(t, 'a', 2)
    1
    >>> h(t, 'b', 2)
    2
"""

def f(a, b):
    return getattr(a, b)

def g(a, b, c):
    return getattr3(a, b, c)

#def h(a, b, c):
#    return getattr(a, b, c)