{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "class A(object):\n", " def __init__(self, v, *args, **kwargs):\n", " print \"A:init:v[{0}]\".format(v)\n", " kwargs['v']=v\n", " super(A, self).__init__(*args, **kwargs)\n", " self.v = v" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "class MixInF(object):\n", " def __init__(self, *args, **kwargs):\n", " print \"IObject:init\"\n", " def f(self, y):\n", " print \"IObject:y[{0}]\".format(y)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "class B(MixInF):\n", " def __init__(self, v, *args, **kwargs):\n", " print \"B:init:v[{0}]\".format(v)\n", " kwargs['v']=v\n", " super(B, self).__init__(*args, **kwargs)\n", " self.v = v\n", " def f(self, y):\n", " print \"B:f:v[{0}]:y[{1}]\".format(self.v, y)\n", " super(B, self).f(y)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "class C(MixInF):\n", " def __init__(self, w, *args, **kwargs):\n", " print \"C:init:w[{0}]\".format(w)\n", " kwargs['w']=w\n", " super(C, self).__init__(*args, **kwargs)\n", " self.w = w\n", " def f(self, y):\n", " print \"C:f:w[{0}]:y[{1}]\".format(self.w, y)\n", " super(C, self).f(y)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "class Q(C,B,A):\n", " def __init__(self, v, w):\n", " super(Q, self).__init__(v=v, w=w)\n", " def f(self, y):\n", " print \"Q:f:y[{0}]\".format(y)\n", " super(Q, self).f(y)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "q = Q(5,6)\n", "q.f(7)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "C:init:w[6]\n", "B:init:v[5]\n", "IObject:init\n", "Q:f:y[7]\n", "C:f:w[6]:y[7]\n", "B:f:v[5]:y[7]\n", "IObject:y[7]\n" ] } ], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "class Q1(A,B,C):\n", " def __init__(self, v, w):\n", " super(Q1, self).__init__(v=v, w=w)\n", " def f(self, y):\n", " print \"Q1:f:y[{0}]\".format(y)\n", " super(Q1, self).f(y)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 7 }, { "cell_type": "code", "collapsed": false, "input": [ "q = Q1(5,6)\n", "q.f(7)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "A:init:v[5]\n", "B:init:v[5]\n", "C:init:w[6]\n", "IObject:init\n", "Q1:f:y[7]\n", "B:f:v[5]:y[7]\n", "C:f:w[6]:y[7]\n", "IObject:y[7]\n" ] } ], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": [ "class Q2(C,A,B):\n", " def __init__(self, v, w):\n", " super(Q2,self).__init__(v=v, w=w)\n", " def f(self, y):\n", " print \"Q2:f:y[{0}]\".format(y)\n", " super(Q2,self).f(y)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": [ "q = Q2(5,6)\n", "q.f(7)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "C:init:w[6]\n", "A:init:v[5]\n", "B:init:v[5]\n", "IObject:init\n", "Q2:f:y[7]\n", "C:f:w[6]:y[7]\n", "B:f:v[5]:y[7]\n", "IObject:y[7]\n" ] } ], "prompt_number": 10 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 10 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }