# HG changeset patch # User Paul Boddie # Date 1241830458 -7200 # Node ID 4db18d4b2a85bfe400af97b3b6896438e8076204 # Parent 6bcd2a7c7a2ae7b8fad879658ebbd469d809e41c Removed erroneous remark about __init__ and __call__ defaults. Added a test of __init__ defaults. Improved and renamed the invocation with non-constant defaults test. diff -r 6bcd2a7c7a2a -r 4db18d4b2a85 docs/concepts.txt --- a/docs/concepts.txt Sat May 09 01:45:42 2009 +0200 +++ b/docs/concepts.txt Sat May 09 02:54:18 2009 +0200 @@ -228,11 +228,6 @@ attributes in the structure correspond to the default arguments for each function, if any. -The two kinds of structure attribute should be accommodated by both groups of -objects, since without a default argument section, classes and instances may -not employ default arguments in their respective instantiator/__init__ and -__call__ methods. - Structure Types --------------- diff -r 6bcd2a7c7a2a -r 4db18d4b2a85 tests/call_func_default_dynamic.py --- a/tests/call_func_default_dynamic.py Sat May 09 01:45:42 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -def f(a, b, c): - return c - -def h(a, b, c=f(1, 2, 3)): - return c - -h(1, 2, 3) -h(1, 2) - -# vim: tabstop=4 expandtab shiftwidth=4 diff -r 6bcd2a7c7a2a -r 4db18d4b2a85 tests/call_func_default_non_constant.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/call_func_default_non_constant.py Sat May 09 02:54:18 2009 +0200 @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +def f(a, b, c): + return b + +def h(a, b, c=f(5, 4, 3)): + return c + +x = h(1, 2, 3) # -> 3 +y = h(1, 2) # -> 4 + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 6bcd2a7c7a2a -r 4db18d4b2a85 tests/class_init_defaults.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/class_init_defaults.py Sat May 09 02:54:18 2009 +0200 @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +class C: + def __init__(self, x=1, y=2, z=3): + self.x = x + self.y = y + self.z = z + +c = C() + +# vim: tabstop=4 expandtab shiftwidth=4