Making a read only attribute in Python

Veröffentlicht am: 17 Oktober 2022
auf dem Kanal: Python Morsels
1,289
21

If you need to make a read-only attribute in Python, you can turn your attribute into a property that delegates to an attribute with almost the same name (but with an underscore prefix).

Read an article version at https://pym.dev/making-read-only-attr...

More Python screencasts at https://pym.dev/screencasts/

00:00 A property is like an auto-updating attribute
00:42 Properties can make read-only attributes
01:55 Using an underscore prefix for internal attributes
02:34 The single underscore prefix is just a convention
03:12 The property decorator can make a read-only attribute


Auf dieser Seite können Sie das Online-Video Making a read only attribute in Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Python Morsels 17 Oktober 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 1,289 Mal angesehen und es wurde von 21 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!