extinherit.pyx 507 Bytes
Newer Older
1 2 3 4 5 6 7
cdef class Parrot:
    cdef object name
    cdef int alive

cdef class Norwegian(Parrot):
    cdef object plumage_colour

Stefan Behnel's avatar
Stefan Behnel committed
8 9 10 11 12 13 14
def create():
    cdef Parrot p
    p = Norwegian()
    p.alive = 1
    return p

def rest(Norwegian polly):
15 16 17 18 19
    """
    >>> p = create()
    >>> rest(p)
    0
    """
20 21
    cdef Parrot fred
    cdef object spam
Stefan Behnel's avatar
Stefan Behnel committed
22 23
    spam = None

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

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

    return fred.alive