Ruby’s “method_missing” in Python [duplicate]
Possible Duplicate: Python equivalent of Ruby's 'method_missing' Is there any technique available in Python for intercepting messages (method calls) like the method_missing technique in Ruby? As others have mentioned, in Python, when you execute o.f(x) , it's really a two-step operation: First, get the f attribute of o , then call it with parameter x . It's the first step that fails because there is no attribute f , and it's that step that invokes the Python magic method __getattr__ . So you have to implement __getattr__ , and what it returns must be callable. Keep in mind, if you also try to