def hang(): class M(object): def __getattribute__(self, n): print 'hello' # this will be never called class A(object): def __getattribute__(self, n): M.__getattribute__(self, n) # this will never return A().something # any name hang()