Can you use __getattr__ here instead? It'll avoid the code above.