Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Mastering Object-oriented Python
  • Toc
  • feedback
Mastering Object-oriented Python

Mastering Object-oriented Python

By : Steven F. Lott
4.2 (13)
close
Mastering Object-oriented Python

Mastering Object-oriented Python

4.2 (13)
By: Steven F. Lott

Overview of this book

Table of Contents (26 chapters)
close
Mastering Object-oriented Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Some Preliminaries
Index

Chapter 3. Attribute Access, Properties, and Descriptors

An object is a collection of features, including methods and attributes. The default behavior of the object class involves setting, getting, and deleting named attributes. We often need to modify this behavior to change the attributes available in an object.

This chapter will focus on the following five tiers of attribute access:

  • We'll look at built-in attribute processing, which is the simplest, but least sophisticated option.

  • We'll review the @property decorator. A property extends the concept of an attribute to include the processing defined in method functions.

  • We'll look at how to make use of the lower-level special methods that control attribute access: __getattr__(), __setattr__(), and __delattr__(). These special methods allow us to build more sophisticated attribute processing.

  • We'll also take a look at the __getattribute__() method, which provides more granular control over attributes. This can allow us to write very unusual attribute...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete