[issue20380] __defaults__ changed by *args
Yury Selivanov added the comment: Though perhaps a note in the documentation would be helpful for future confused people. I agree. Also, __kwdefaults__ wasn't documented. Please take a look at the attached patch. -- keywords: +patch nosy: +yselivanov Added file: http://bugs.python.org/file33752/inspect_doc_20380_01.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20380] __defaults__ changed by *args
Ram Rachum added the comment: Looks good. Ideally there would be a more details explanation and an example. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20380] __defaults__ changed by *args
Yury Selivanov added the comment: Ram, those are internal attributes. I.e. it's not recommended to use them directly, there are better instruments for that, such as 'inspect.signature'. Hence, I don't think that having an example/detailed explanation here is really necessary. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20380] __defaults__ changed by *args
Ram Rachum added the comment: I take your point and I agree. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20380] __defaults__ changed by *args
Roundup Robot added the comment: New changeset fc32459495fc by Yury Selivanov in branch 'default': doc/inspect: Clarify docs for __defaults__, add docs for __kwdefaults__ #20380 http://hg.python.org/cpython/rev/fc32459495fc -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20380] __defaults__ changed by *args
New submission from Ram Rachum: Check the following example out. Putting *args in a function makes its __defaults__ be empty. Python 3.4.0b2 (v3.4.0b2:ba32913eb13e, Jan 5 2014, 16:13:26) [MSC v.1600 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. def f(x, *args, y='meow'): pass ... f.__defaults__ def g(x, y='meow'): pass ... g.__defaults__ ('meow',) -- components: Interpreter Core messages: 209085 nosy: cool-RR priority: normal severity: normal status: open title: __defaults__ changed by *args type: behavior versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20380] __defaults__ changed by *args
Larry Hastings added the comment: That's because in f, y is after *args, so it is a keyword-only parameter. Its default value is in __kwdefaults__. If you move y to before *args, its default will be in __defaults__. This is working as designed. -- nosy: +larry resolution: - invalid stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20380] __defaults__ changed by *args
Ram Rachum added the comment: Though perhaps a note in the documentation would be helpful for future confused people. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20380] __defaults__ changed by *args
Ram Rachum added the comment: My mistake. Thanks for the clarification. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20380 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com