Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3961
| Date | 2011-04-24 14:44 -0700 |
|---|---|
| From | Ken Seehart <ken@seehart.com> |
| Subject | Re: Function __defaults__ |
| References | <4db3f444$0$29978$c3e8da3$5496439d@news.astraweb.com> <BANLkTik4pVW+M_9b8ZFRwLS_L9w2QSMKNg@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.802.1303681500.9059.python-list@python.org> (permalink) |
Oops, I must correct myself. Please ignore my previous post. As Daniel points out, Writable is specified in the Python 3 documentation. Apparently I was reading the documentation with only my right eye open, and the Writable tag fell on my blind spot. I concur that this unambiguously implies that the attribute should work as advertised after being written. This is not a bug in Jython. As Daniel points out the attribute was renamed from func_defaults to __defaults__ in python 3. Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06) [Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_24 Type "help", "copyright", "credits" or "license" for more information. >>> def foo(x=4): ... print x ... >>> foo() 4 >>> foo.func_defaults (4,) >>> foo.func_defaults = (3,) >>> foo() 3 >>> So it works correctly in Jython 2.x. Conclusion: Not an implementation detail, and safe to use. Ken On 4/24/2011 10:18 AM, Daniel Kluev wrote: > http://docs.python.org/dev/reference/datamodel.html > Callable types > ... > Special attributes: > ... > __defaults__ A tuple containing default argument values for those > arguments that have defaults, or None if no arguments have a default > value Writable > > I don't see any 'implementation detail' mark there, and 'Writable' > IMHO means it can be used. > > On Mon, Apr 25, 2011 at 4:02 AM, Benjamin Kaplan > <benjamin.kaplan@case.edu> wrote: >> Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54) > In 2.x it was func_defaults (http://docs.python.org/reference/datamodel.html) > __defaults__ is 3.x feature >
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
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