Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Controlling Conversion 6:24
- Dream Car 1 objective
- Math 6:22
- Multiplication 2 objectives
- Emulating Built-ins 8:01
- Iterable Album 1 objective
- Subclassing Built-ins 10:28
- Double 3 objectives
- Frustration 1 objective
- Constructicons 5:26
- Dream Vacation 1 objective
- Special Methods 7:30
- Proper Properties 2 objectives

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Whether we like it or not, someone, somewhere, is going to turn an instance of our class into a string. Or an int. Let's make sure it happens like we want.
You can read more about the magic methods. There are a lot of them, though, so don't try and memorize them all. You'll find that, over time, you memorize the most useful ones. Here are the ones I recommend you start with:
-
__str__
- Control how your instances turn into strings -
__int__
- Controlint()
conversion -
__init__
- Customize the initialization of your instances
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Cameron Ganley
4,049 Points1 Answer
-
PLUS
Begana Choi
Courses Plus Student 13,126 Points1 Answer
-
keith frazier
Python Development Techdegree Student 5,771 Points1 Answer
-
Keith Griffin
4,833 Points1 Answer
-
Aizah Sadiq
2,435 Points1 Answer
-
Aizah Sadiq
2,435 Points2 Answers
-
Arink Bertrand
10,165 Points1 Answer
-
Max Palmer
2,920 Points1 Answer
-
Elena Chen
1,503 PointsWhy am I getting this error? AttributeError: type object 'str' has no attribute 'value'
Posted by Elena ChenElena Chen
1,503 Points1 Answer
-
Kohei Ashida
4,882 Points2 Answers
-
brandon supinski
Python Development Techdegree Graduate 27,983 Points3 Answers
-
daniel steinberg
14,651 Points1 Answer
-
Kurobe Kuro^T_T^
5,369 Points1 Answer
-
anthony pizarro
1,983 Points1 Answer
-
Leo Marco Corpuz
18,975 Points2 Answers
-
ryanosten
PHP Development Techdegree Student 29,615 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up