edge_distance_from_origin’s code is slightly different from before because it now accesses the base class’s
distance_from_origin property instead of calling a
- 6. Object-Oriented Programming
- from Programming in Python 3: A Complete Introduction to the Python Language, Second Edition
- Publisher: Addison-Wesley Professional
- Released: November 2009
this is a bit misleading. You got to implement distance_from_origin as a property in the base class. If you leave the base class implementation as a method, you still need to call base class as method. In addition, if you haven't reimplemented a method or reassigned a variable in the derived class, you can call that method or variable either by super(). or self. This is Python's polymorphism at work. Syntactically, it will work either way However, for those methods that you are trying to reimplement by reusing some of the functionality of the super class i.e. you need to delegate some work to the super class to reuse its implementation, you got to call super().method_name in that case. u can't use self bcoz of recursion ...
Share this highlighthttp://www.safaribooksonline.com/a/programming-in-python/13247361/