Python's property() and Managing Attributes

preview_player
Показать описание
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.

This is a portion of the complete course, which you can find here:

The rest of the course covers:
- Creating write-only attributes
- Creating consistent and backwards-compatible APIs for your classes
- Validating input values
- Overriding properties in subclasses
Рекомендации по теме
Комментарии
Автор

This is the clearest, best tutorial I have come across. Thank you very much..

cigdemylmaz
Автор

26:54 this is exactly what I needed to hear. There is a lot of misleading, or at least unknowledgeable youtubers giving advice, information out there that fails to articulate this subtle difference. That subtle difference is using the radius property within the class initializer to set the value of radius, which means it goes through the setter method. THAT is key.

QuintinMassey
Автор

typo in 0:29
line 2 should read "self_radius = radius"

georgplaz