Sunday, 15 June 2014

python - Function Arguments with Composition -



python - Function Arguments with Composition -

this illustration of *composition larn python hard way. illustration found here: example 44 -- see illustration 44.e (under header "composition")

when i'm using call:

self.other.implicit()

does child() class utilize function arguments function definition within other() class, or utilize arguments function definition within child() class?

class other(object): def override(self): print "other override()" def implicit(self): print "other implicit()" def altered(self): print "other altered()" class child(object): def __init__(self): self.other = other() def implicit(self): self.other.implicit() def override(self): print "child override()" def altered(self): print "child, before other altered()" self.other.altered() print "child, after other altered()" boy = child() son.implicit() son.override() son.altered()

does child() class inherit function arguments function definition within other() class, or utilize arguments function definition within child() class?

they both have same arguments - 1 positional argument (which used self). so, there's no difference between functions in respect.

does child() class inherit function arguments function definition within other() class

child not inherit other; inherits object, there no inheritance of sort.

python inheritance

No comments:

Post a Comment