style) class instance invokes the `
__getattribute__() ` method that performs the following:

  * Check the class hierarchy using MRO (but do not examine metaclasses): 
    * If a data (overriding) descriptor is found in class hierarchy, call its ` __get__() ` method; 
  * Otherwise check the instance ` __dict__ ` (assuming no ` __slots__ ` for the sake of example). If an attribute is there, return it; 
  * If attribute not in ` instance.__dict__ ` but found in the class hierarchy: 
    * If (non-data) descriptor, call its ` __get__() ` method; 
    * If not a descriptor, return the attribute itself; 
  * If still not found, invoke ` __getattr__() ` , if implemented on a class; 
  * Finally give up and raise ` AttributeError ` . 

* * *

  1. I totally made this term up, do not use it in a conversation when trying to sound smart. :)  ↩ 

###  Share this:

  * [ Twitter  ](https://blog.peterlamut.com/2018/11/04/python-attribute-lookup-explained-in-detail/?share=twitter "Click to share on Twitter")
  * [ Facebook  ](https://blog.peterlamut.com/2018/11/04/python-attribute-lookup-explained-in-detail/?share=facebook "Click to share on Facebook")
  * 

Like  Loading...

###  _Related_

![](https://1.gravatar.com/avatar/47889a61e55c396e2ea18b0de05fa8a63f36cf32eddcf552613be0ebca37fb83?s=49&d=identicon&r=G)
Author  [ Peter Lamut ](https://blog.peterlamut.com/author/peterlamut/) Posted
on  [ November 4, 2018  ](https://blog.peterlamut.com/2018/11/04/python-
attribute-lookup-explained-in-detail/) Tags  [ Attribute lookup
](https://blog.peterlamut.com/tag/attribute-lookup/) , [ Descriptors
](https://blog.peterlamut.com/tag/descriptors/) , [ Metaclasses
](https://blog.peterlamut.com/tag/metaclasses/) , [ Python
](https://blog.peterlamut.com/tag/python/)

##  Leave a comment  [ Cancel reply ](/2018/11/04/python-attribute-lookup-
explained-in-detail/#respond)

Δ

This site uses Akismet to reduce spam. [ Learn how your comment data is
processed ](https://akismet.com/privacy/) .

##  Post navigation

[ Previous  Previous post:  A few thoughts on working remotely
](https://blog.peterlamut.com/2018/05/12/a-few-thoughts-on-working-remotely/)

[ Next  Next post:  Enums to replace hardcoded string constants
](https://blog.peterlamut.com/2019/02/22/enums-to-replace-hardcoded-string-
constants/)

##  Recent Posts

  * [ Distinguishing between None and missing values in dictionaries with a sentinel ](https://blog.peterlamut.com/2020/04/01/distinguishing-between-none-and-missing-values-in-dictionaries-with-a-sentinel/) April 1, 2020 
  * [ Dropping into a debugger with the built-in debugger() function ](https://blog.peterlamut.com/2019/06/24/dropping-into-a-debugger-with-the-built-in-debugger-function/) June 24, 2019 
  * [ Enums to replace hardcoded string constants ](https://blog.peterlamut.com/2019/02/22/enums-to-replace-hardcoded-string-constants/) February 22, 2019 
  * [ Python attribute lookup explained in detail ](https://blog.peterlamut.com/2018/11/04/python-attribute-lookup-explained-in-detail/) November 4, 2018 
  * [ A few thoughts on working remotely ](https://blog.peterlamut.com/2018/05/12/a-few-thoughts-on-working-remotely/) May 12, 2018 

##  About the Author

![](https://1.gravatar.com/avatar/47889a61e55c396e2ea18b0de05fa8a63f36cf32eddcf552613be0ebca37fb83?s=96&d=identicon&r=G)  
I am an experienced software engineer, primarily using Python and JavaScript
in my day-to-day work, putting a strong emphasis on writing clean and
maintainable code.

I use Linux, like to crack jokes, and enjoy attending developer meetups and
conferences like EuroPython.

I do not own any pets or hair care products.

Search for:  Search

##  Tags

  * [ Attribute lookup ](https://blog.peterlamut.com/tag/attribute-lookup/)
  * [ ChainMap ](https://blog.peterlamut.com/tag/chainmap/)
  * [ Classmethod ](https://blog.peterlamut.com/tag/classmethod/)
  * [ CPython internals ](https://blog.peterlamut.com/tag/cpython-internals/)
  * [ Debugging ](https://blog.peterla