Name: [004] Jerol Harrington
Member: 106 months
Authored: 3 videos
Description:

An Introduction To Python Objects Using IPython (Part-2) [ID:009] (2/3)

in series: An Introduction to Python Objects, using IPython

video tutorial by Jerol Harrington, added 03/07

(Showmedo is undergoing major changes. To report any problems viewing the videos please email us and include browser and OS specifics. Cheers - Kyran.)

In this ShowMeDo we show you how to create your own objects and methods, how to get a handle on self and even venture into ... namespaces

Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 2539 (since July 30th)
  • Plays in last week: 5
  • Published: Sometime before 1st March 2007 (in other words - we don't remember!)

Thank-yous, questions and comments

If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?

You may also want to see our ShowMeDo Google Group to speak to our active users and authors.

Your email address will not be published.

Show some quick comments >>








All comments excluding tick-boxed quick-comments

Thank you for this video.


32. benjamin serrato Mon, 19 Jul 2010 20:06

This one was helpful too, thanks. But I was left wondering what happens if you instantiate a class without attaching a name (i.e. label) to the object? e.g.

class aaa:

pass

>>>aaa()

I'm sure the class is instatiated, but I'm not sure what happens after that. Am I able to access the instantiated object with some clever trick by listing all active objects, cross referencing the objects with bound names, and attaching labels to the nameless objects? Or, are they as-good-as-gone, just left for the GC to come by and clean up?

I'm fairly confident it's the latter, but I wonder and I'm not sure how to check as, after all, I don't have an object to id() :)


Hi Patrick,

objx.py is just a script that contains objects such as classes. I use it with the IPython "run" command to load the script in order to demonstrate different qualities of Python's classes. I use IPython all the time with tiny code fragments to test ideas or to clarify points of confusion.

If you are learning the language, I suggest running a Python-aware editor, IPython, and the script in the same directory. Then you can just toggle between IPython and the editor. This is what I do in the tutorial, and what I do for most of my personal programming.

Thank you for your comments.

Jerol


Noticed the videos were made back in 2006. I just started with Py coming out of Java and was confused but the videos helped 99%. Rating = Excellent. The 1% was the loading of "run objx.py". Is objx.py a class with inner classes in it or just a holder?


Very good and easy to understand, but you need to go a bit faster.


28. David Hickok Fri, 05 Mar 2010 07:12

I learned you can call a method from the class rather than an instance, thanks.


I was practicing a bit about inheritance with your exercises and it can be even more things to find out and more questions coming over, but thanks to your introduction (and some mistakes in my typing...) I am understanding much more the way that classes and objects are defined.

Evaristo


25. anonymous Sun, 20 Dec 2009 15:46

Best discussion of objects I've ever seen!!!!!


Very good. So simply put.


23. anonymous Sat, 07 Nov 2009 00:31

great way to illustrate inheritance in python


cool! that was some good info for me. Now I can impress my friend with a solution to a coding dilemma he is currently facing.


Sorry Jerol. I found this presentation confusing. I'd like to have had a clear distinction between classes and instances (were the classes all 3 letters and the instances all 1 letter???).


20. anonymous Sun, 20 Sep 2009 19:27

Thanks!


19. anonymous Thu, 20 Aug 2009 09:29

Very good tutorial, clearly explained.


18. anonymous Tue, 11 Aug 2009 17:44

Very, very good content. This was great at understanding the way data flows which I needed before getting started. Your series has filled in more gaps for me then anything yet.


17. anonymous Wed, 05 Aug 2009 21:16

Jerol has the nack for translating difficult concepts into easy, yet insightful, explanations.


16. anonymous Mon, 27 Jul 2009 22:47

The part about "self" being passed as an argument was a bit hazy. Otherwise, this was one of the best explanation about inheritance that I have seen. Thank you.


15. anonymous Sun, 12 Jul 2009 21:23

Useful. Many thanks.


14. anonymous Sun, 05 Jul 2009 13:36

Great video, very easy to follow. My only complaint is that the mouse clicking and keyboard typing is very loud, and a little distracting as it is not really in sync to the image.


Excellent explanation. Very basic in scope, but handles the necessities of understanding class objects very well

I would appreciate more detail and more depth with perhaps a level more complexity.


12. anonymous Fri, 19 Jun 2009 23:38

Thank you Jerol! I have been learning python for a couple of weeks now, and this is by far the most helpful. I finally understand inheritance!!


11. anonymous Sat, 25 Apr 2009 19:29

Good tutorial, I didn't really understand inheritance, this video made it more clear.

Thanks. Hope you do more.


Hi

This was sooo goood. You made it simple and easy to understand. trying to understand this stuff by reverse engineering sample codes can be frustrating/


Hi

This was sooo goood. You made it simple and easy to understand. trying to understand this stuff by reverse engineering sample codes can be frustrating/


Hi DiggDog3000,

Thanks for the comment. I didn't mean to imply that passing an

instance directly to a class object was a normal procedure. Rather, I

wanted to prepare the viewer for the next screencast, which

illustrates __init__. If we use __init__ to initialize the subclass, we

must also pay attention to the superclass, if applicable. The

superclass's __init__ method is not called automatically. We can do

this by passing an instance of the subclass directly to the

superclass's __init__ . All that I was trying to do was show how we

could pass an instance of a class or subclass directly to a class

(unbound) method. Note that we go up the inheritance chain. It doesn't

work the other way. (xxx.show(y) = OK yyy.show(x) = ERROR). Note that

we get xxx.show's method "This is xxx", not yyy.show "This is yyy".

This is why your test case failed.

Keep experimenting with the shell. That's the best way to learn. Also,

maybe the next screencast in the series will clear things up a bit.

Good Luck!

Jerol


Thanks Jerol! I got a little lost at the end. I was wondering if you someone could explain the significance of zzz.show(z). I see we have a class, using its method that has been passed an instance of itself. Are we saying that self must be any instance of the class?

-

I tried passing an instance of xxx to zzz.show(), but that didn't work. And when I made an instance of zzz called w -ie [ w = zzz() ], this worked (ie. zzz.show (w).


I have been wanting to learn more about objects...this is a good start.


xxx, yyy, zzz made for a very clear example of inheritance of class attributes through successive generations. Thanks!


xxx, yyy, zzz, shows inheritance of classes through successive generations very clearly.

Thanks!


Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Jerol

By the Same Author

Content

Feedback

Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.

feedback@showmedo.com