Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
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 upRelated 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