Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Python Basics: Building Systems With Classes (Summary)

Congratulations! You now know how to use classes for object-oriented programming (OOP) in Python. Specifically, you can:

  • Compose classes together
  • Inherit and override behavior from other classes
  • Creatively mix and match these approaches

With these skills to your name, you’re now ready to tackle creating complex systems and writing sleek, Pythonic code.

To reinforce what you’ve learned here, complete the quiz in the next lesson. Then, head over to Python Basics Exercises: Building Systems With Classes.

Then, keep growing your skill set as a programmer by continuing with the other Python Basics courses and getting yourself a copy of Python Basics: A Practical Introduction to Python 3.

You can also check out these Real Python video courses:

If you’d prefer to read, then these written tutorials are for you:

Download

Sample Code (.zip)

1.3 KB
Download

Course Slides (.pdf)

6.2 MB

00:00 That was Python Basics: Building Systems With Classes. In this course, you’ve discovered that you can compose classes together. You can make one class have attributes that are members of another class, creating layers of functionality in this way.

00:17 You can inherit and override behaviors from other classes to create variations. You can also mix and match these approaches. Building systems with classes is a creative activity, and it’s up to you where to draw the boundaries.

00:31 Object-oriented programming is a big topic. There have been many books written on the subject, and here at Real Python, you have a bunch of extra articles if you want to dive deeper into any of the concepts covered here. For instance, an article dedicated to inheritance and composition.

00:49 It compares the two practices, shows you what’s involved in each one, gives you examples and recommendations for how to use that in your code. You’ve got Supercharge Your Classes With Python super(), which goes into great detail about the super() function and how to use that.

01:06 You might also be interested in something called Data Classes in Python 3.7+. Data classes are a special type of class which allow you to define a class with minimal code.

01:17 They can be very useful if you’re just storing data in a class.

01:22 You also have Python’s property(): Add Managed Attributes to Your Classes. This is an advanced way to customize the behavior of your attributes.

01:32 Last but not least, you have providing Multiple Constructors in Your Python Classes. You’ve looked at the constructor function, but there are other ways of creating variations on constructors.

01:43 Maybe you want a few options for how to construct your class.

01:48 All of the resources mentioned here have both written tutorials and extra video courses. Definitely check them out if you’re interested in going deeper into the OOP world.

02:00 And that’s been Python Basics: Building Systems With classes. Thank you for watching and following along.

Become a Member to join the conversation.