extinherit.pyx 511 Bytes
Newer Older
1
__doc__ = u"""
Stefan Behnel's avatar
Stefan Behnel committed
2 3 4 5 6
    >>> p = create()
    >>> rest(p)
    0
"""

7 8 9 10 11 12 13
cdef class Parrot:
    cdef object name
    cdef int alive

cdef class Norwegian(Parrot):
    cdef object plumage_colour

Stefan Behnel's avatar
Stefan Behnel committed
14 15 16 17 18 19 20
def create():
    cdef Parrot p
    p = Norwegian()
    p.alive = 1
    return p

def rest(Norwegian polly):
21 22
    cdef Parrot fred
    cdef object spam
Stefan Behnel's avatar
Stefan Behnel committed
23 24
    spam = None

25 26 27
    fred = polly
    polly = fred
    polly = spam
Stefan Behnel's avatar
Stefan Behnel committed
28 29 30
    assert polly is None
    assert fred.alive

31
    spam = polly
Stefan Behnel's avatar
Stefan Behnel committed
32 33 34
    fred.alive = 0

    return fred.alive