Function __defaults__

Daniel Kluev dan.kluev at
Sun Apr 24 23:47:43 CEST 2011

On Mon, Apr 25, 2011 at 8:21 AM, Ken Seehart <ken at> wrote:
> Good point, Benjamin.  I didn't think of testing on Jython before
> answering.  For practical purposes it's a really good idea to test obscure
> features against all potential target platforms.
> In this case, I would argue that Benjamin's test demonstrates a bug in
> Jython.

It doesn't. __defaults__ was added in 3.x (and it is documented).
Prior to that, in 2.x, there was func_defaults.

Jython is not in 3.x yet, so you should not expect 3.x features there.
As for func_defaults, its there and supported as documented:

Jython 2.5.1+ (Release_2_5_1:exported, Mar 21 2010, 01:00:17)
[Java HotSpot(TM) Server VM (Sun Microsystems Inc.)] on java1.6.0_22
Type "help", "copyright", "credits" or "license" for more information.
>>> def test(a=123):
...     return a
>>> test()
>>> test.func_defaults
>>> test.func_defaults = (456,)
>>> test()

With best regards,
Daniel Kluev

More information about the Python-list mailing list