Managing Attributes With Python's property() (Overview)
With Python’s property()
, you can create managed attributes in your classes. You can use managed attributes, also known as properties, when you need to modify their internal implementation without changing the public API of the class. Providing stable APIs can help you avoid breaking your users’ code when they rely on your classes and objects.
Properties are arguably the most popular way to create managed attributes quickly and in the purest Pythonic style.
In this video course, you’ll learn how to:
- Create managed attributes or properties in your classes
- Perform lazy attribute evaluation and provide computed attributes
- Avoid setter and getter methods to make your classes more Pythonic
- Create read-only, read-write, and write-only properties
- Create consistent and backwards-compatible APIs for your classes
00:00
Managing Attributes With Python’s property()
.
00:05
With Python’s property()
, you can create managed attributes in your classes. You can use managed attributes, also known as properties, when you need to modify their internal implementation without changing the public API of the class.
00:20 Providing stable APIs can help you avoid breaking your user’s code when they rely on your classes and objects. Properties are arguably the most popular way to create managed attributes quickly and in the purest Python style.
00:35 In this course, you’ll learn how to create managed attributes or properties in your classes, perform lazy attribute evaluation and provide computed attributes, avoid setter and getter methods to make your classes more Pythonic, create read-only, read-write, and write-only properties, and create consistent and backward-compatible APIs for your classes.
00:59
You’ll also write a few practical examples that will use property()
for validating input data, computing attribute values, dynamically logging your code, and more. To get the most out of this course, you should know the basics of object-oriented programming and decorators in Python. So now you know what’s going to be covered, let’s get started.
Become a Member to join the conversation.