Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3962

Re: Function __defaults__

References <4db3f444$0$29978$c3e8da3$5496439d@news.astraweb.com> <BANLkTi=hLzcxEGMtsZiSVGdN4bi4A4DCLw@mail.gmail.com> <4DB49473.4000204@seehart.com>
Date 2011-04-25 08:47 +1100
Subject Re: Function __defaults__
From Daniel Kluev <dan.kluev@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.803.1303681671.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Apr 25, 2011 at 8:21 AM, Ken Seehart <ken@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

-- 
With best regards,
Daniel Kluev

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Function __defaults__ Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-24 09:58 +0000
  Re: Function __defaults__ Terry Reedy <tjreedy@udel.edu> - 2011-04-24 12:48 -0400
  Re: Function __defaults__ Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-04-24 13:02 -0400
  Re: Function __defaults__ Daniel Kluev <dan.kluev@gmail.com> - 2011-04-25 04:18 +1100
  Re: Function __defaults__ Ken Seehart <ken@seehart.com> - 2011-04-24 10:07 -0700
    Re: Function __defaults__ Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-25 02:00 +0000
  Re: Function __defaults__ Ken Seehart <ken@seehart.com> - 2011-04-24 14:44 -0700
  Re: Function __defaults__ Daniel Kluev <dan.kluev@gmail.com> - 2011-04-25 08:47 +1100
  Re: Function __defaults__ Terry Reedy <tjreedy@udel.edu> - 2011-04-24 17:53 -0400
  Re: Function __defaults__ Ken Seehart <ken@seehart.com> - 2011-04-24 14:54 -0700
  Re: Function __defaults__ "Colin J. Williams" <cjw@ncf.ca> - 2011-04-25 07:59 -0400
  Re: Function __defaults__ Ken Seehart <ken@seehart.com> - 2011-04-25 05:30 -0700
  Re: Function __defaults__ "Colin J. Williams" <cjw@ncf.ca> - 2011-04-25 10:24 -0400

csiph-web