Python With Spyder 9: Objects Part 2 – Attributes and Methods and a Few Spyder “Tricks”

This is the 9th in a series of videos providing a tutorial on Python 2.7 using Anaconda Python and the Spyder IDE. Click here to go to a “home page” for the video series.

This video is the second of four videos introducing objects in Python. This video discusses attributes and methods and also demonstrates a few features of the Spyder IDE.

The source code used in this video can be found here. You can right click on the link and use “Save As” to save the file.

Note: The source code files are plain text files with a “.txt” extention. You will probably want to change the extensions to “.py” after you download them. If you do so, please be aware that if you have Python installed, the file will become executable, so that it will run if you click on it (accidentally or otherwise).

The video is about 17 minutes long.


Next Video: Private Data and Encapsulation

Video Index: Attributes and Methods

Click on the topics below to jump to that location in the video.

Time Topic
00:00Title Slide
00:03Location of source code
00:06Review of supermarket product example
00:56Spyder “trick:” Connecting a console to the editor
02:20Spyder “trick:” Code cells in the editor (“#%%”)
03:20Spyder “trick:” Executing a code cell with the toolbar button
04:20Spyder “trick:” Executing a code cell with cntrl-Enter
04:42Spyder “trick:” Executing a code cell with shift-Enter
05:16Most object attributes created dynamically using __init__()
05:37Object attributes do not have to be created dynamically and can be defined for every instance
07:01Terminology: Attribute
07:41Review of __init__()
07:54__init__() is a private method
08:10“Public” methods
09:32Spyder “trick:” Comment and uncomment blocks of code (cntrl-1)
10:20Function definition and indentation for methods
10:41Method example: a Print() function
11:02The first argument of a method is self
11:23Special formatting symbols in strings: “\n” for newline, “\n” for tab
11:49String concatenation (joining) with “+”
12:52Python line continuation with “\” at the end of the line
13:27Convert a number to a striing with the built-in function str()
14:12Run the class definition code for the class Product
14:28Run the code to create two instances of Product
14:38Use the Print() method for the two instances
15:30The built-in function dir()

Next Video: Private Data and Encapsulation

1 thought on “Python With Spyder 9: Objects Part 2 – Attributes and Methods and a Few Spyder “Tricks”

Leave a Comment

Time limit is exhausted. Please reload CAPTCHA.