Function __defaults__

Ken Seehart ken at seehart.com
Sun Apr 24 17:54:33 EDT 2011


Gotta love that email latency. :-D
Ken

On 4/24/2011 2:47 PM, Daniel Kluev wrote:
> On Mon, Apr 25, 2011 at 8:21 AM, Ken Seehart<ken at seehart.com>  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()
> 123
>>>> test.func_defaults
> (123,)
>>>> test.func_defaults = (456,)
>>>> test()
> 456
>




More information about the Python-list mailing list