Python 2.7 Tutorial Pt 8

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
3,518
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Nov 2, 2010

I explain how Object Oriented Programming is used with Python 2.7. I cover some of the more complicated subjects including how to: * Allow the user to define an infinite number of attributes * Use Inheritance and what it is * Override Methods * Use Polymorphism and what it is * Inherit from 2 more more classes * Use many of the built in object methods in Python

All of the code is here: http://bit.ly/9ommng

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (derekbanas)

  • I notest that you call the animal constructer with __name and __owner yet when you make a new attribute it is done as a string 'like so: Animal.setAttribute( 'clean ', Ýes')

    is this because this is a "New" or not pre defined variable? and when you do it with a pre defined attribute it can be done like Animal.setAttribute( __name, 'Jan')?

  • @baffie Yes you are correct

  • When you created the class Dat, you defined the __init__ constructor method by typing "def __init(self, **kvargs):" instead of "def __init__(self, **kvargs):" as you did in the classes Cat and Dog, yet Python did not return an error. Is the constructor different somehow because this subclass inherits from both Dog and Cat, or is this simply an acceptable alternative?

  • @cyborgdale It's just an alternative

  • You are a great instructor. Have you thought of teaching classes?

  • @ribsmcgee1 Thank you, but I dropped out of college in my 3rd year to go work for Apple. I never went back. I like having the freedom to teach whatever I want here. I'm glad you like the tutorials

see all

All Comments (16)

Sign In or Sign Up now to post a comment!
  • What does that super()-function do? I dind't quite get it.

  • Should this work in py 2.5?

  • @baffie first time i saw the video I had no idea what you were talking about, but now it makes perfect sense to ask that question. Good job derekbanas btw

  • @baffie That's "noticed", not "notest".

  • I have several questions Derek, but one at a time. . .On the function set_attributes(self,key,value)­: I don't understand the 2nd line self._attributes[key]=value??? I don't understand the [key] on the end of self._attributes? Why is it written like this? I just don't understand that line at all. If you could explain that to me as if I was a 10yr old, LOL, please.

  • Hey DerekBanas,

    i am realy enjoing these tutorials. Thanks for making them.

    I do have a little question though. When you change your constructor to __init__(self, **kvargs) you did not remove __name and __owner local variables.

    when i make a Animal object does is these two variables still get used or is there some underwater dictionairy where alle the variables are stored?

    

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more