I am trying to doc-test a method that accepts a module object module and a string with the name of the type type_name inside that module : When I am trying to get the type object with getattr (in reality, the method does more than just that), I am getting the error: Is it possible to doc-test this method without
Tag: getattr
Python: inconsistence in the way you define the function __setattr__?
Consider this code: I would expect the same output. However, with CPython 2.5, 2.6 (similarly in 3.2) I get: With PyPy 1.5.0, I get the expected output: Which is the “right” output? (Or what should be the output according to the Python documentation?) Here is the bug report for CPython. Answer I suspect it has to do with a lookup
__getattr__ for static/class variables
I have a class like: Whenever MyClass.Foo or MyClass.Bar is invoked, I need a custom method to be invoked before the value is returned. Is it possible in Python? I know it is possible if I create an instance of the class and I can define my own __getattr__ method. But my scnenario involves using this class as such without