[Tutor] inheritance and super() function in python

Dave Angel davea at davea.name
Wed Apr 23 04:18:11 CEST 2014


Jorge Leon <jorge.a.leon.g at gmail.com> Wrote in message:
> Thank you Steve and Dave for the prompt response and advise, and sorry
> about the format.
> 
> The version of Python I'm working under is 2.7.5. About the .super():
> I'm going to try out the format you gave me for the files, and yes:
> that's exactly how I had it. Something that has stuck from all the C++
> programming I'm doing, which also leads me to believe that it may be
> better for me to step away from using .super() if I don't get the
> program to work as intended when I apply your advise.
> 
> Going to consult more tutorials from the page about inheritance and
> operator and function overloading.
>

Please don't top-post.  Put your comments after the part you're
 quoting,  and delete anything you're not responding to, which
 would certainly be anything following your message.
 

There's another flaw in your call to super.  You had :


 class Cylinder(Obstacle):
   def __init__(self,position, height, radius):
       super(Obstacle,self).__init__(position)

But it looks to me like the last line should be
        super(Cylinder, self).__init__(position)



-- 
DaveA



More information about the Tutor mailing list