1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/getattr_instance_methods_dynamic_chained.py Wed May 01 23:32:25 2013 +0200
1.3 @@ -0,0 +1,25 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +class C:
1.7 + def x(self, obj):
1.8 + return getattr(obj, "y")(obj)
1.9 +
1.10 + def y(self, obj):
1.11 + return getattr(obj, "z")(obj)
1.12 +
1.13 + def z(self, obj):
1.14 + return 1
1.15 +
1.16 +class D:
1.17 + def x(self):
1.18 + return 2
1.19 +
1.20 +def f(obj, attrname):
1.21 + return getattr(obj, attrname)(obj)
1.22 +
1.23 +c = C()
1.24 +d = D()
1.25 +result_1 = f(c, "x")()
1.26 +result_2 = f(d, "x")()
1.27 +
1.28 +# vim: tabstop=4 expandtab shiftwidth=4