2013-11-29 | Paul Boddie | raw files shortlog changelog graph | Added an example of a method with an uncertain default parameter value. | syspython-as-target |
tests/call_func_default_class_attribute_uncertain.py (file) |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tests/call_func_default_class_attribute_uncertain.py Fri Nov 29 01:03:05 2013 +0100 1.3 @@ -0,0 +1,19 @@ 1.4 +#!/usr/bin/env python 1.5 + 1.6 +switch = 0 1.7 + 1.8 +class C: 1.9 + 1.10 + if switch: 1.11 + default = 100 1.12 + else: 1.13 + default = 101 1.14 + 1.15 + def f(self, x=default): 1.16 + return x 1.17 + 1.18 +c = C() 1.19 +result_101 = c.f() 1.20 +result_202 = c.f(202) 1.21 + 1.22 +# vim: tabstop=4 expandtab shiftwidth=4