use getattr only if object doesn't have __getitem__