Is there a way to insert hooks into a native dictionary type to see when a query arrives and what's looked up?

Veek M vek.m1234 at gmail.com
Wed Dec 14 01:11:31 EST 2016


I know that with user classes one can define getattr, setattr to handle 
dictionary lookup. Is there a way to hook into the native dict() type 
and see in real time what's being queried.

I wanted to check if when one does:

x.sin()

if the x.__dict__ was queried or if the Foo.__dict__ was queried.. I 
know method/attribute lookup starts with the instance but was wondering 
if I could see it in action vs defining __getattr__ __setattr__ in Foo 
which is a bit indirect.. and not what I want.



More information about the Python-list mailing list