[issue10918] **kwargs unnecessarily restricted in API
Brian Quinlan br...@sweetapp.com added the comment: Arian, This seems like such an unimportant edge case that I don't want to mess with the API just to accommodate it. If you really need to pass an fn keyword argument, use: .submit(foo, 1, 2, **{'fn': bar}) -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10918] **kwargs unnecessarily restricted in API
Adrian Dries adr...@gmail.com added the comment: What now? Python 3.1.3 (r313:86834, Jan 17 2011, 22:33:40) [GCC 4.4.1] on linux2 Type help, copyright, credits or license for more information. def foo(f, **kw): ... pass ... foo(1, **{'f': 2}) Traceback (most recent call last): File stdin, line 1, in module TypeError: foo() got multiple values for keyword argument 'f' -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10918] **kwargs unnecessarily restricted in API
Brian Quinlan br...@sweetapp.com added the comment: Good point! I'd suggest functools.partial. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10918] **kwargs unnecessarily restricted in API
R. David Murray rdmur...@bitdance.com added the comment: Adrian's suggestions don't look to me like they fiddle with the API, but rather make the behavior match the documented API. The existing behavior is, IMO, a very surprising corner case, especially to a less experienced Python programmer. I do note that assertRaises in unittest has the same issue. However, I think people are quite a bit more likely to run in to the issue with submit, since 'fn' is going to occur as a keyword argument with considerably higher frequency than 'excClass' or 'callableObj'. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10918] **kwargs unnecessarily restricted in API
Ron Adam ron_a...@users.sourceforge.net added the comment: Why is this surprising? def foo(c, c=None): ... pass ... File stdin, line 1 SyntaxError: duplicate argument 'c' in function definition In the previous examples, it finds the duplicate at run time instead of compile time due to not being able to determine the contents of kwargs at compile time. It's just a bug in your code if you do it, and it should raise an exception as it does. -- nosy: +ron_adam ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10918] **kwargs unnecessarily restricted in API
R. David Murray rdmur...@bitdance.com added the comment: The reason that it is surprising is that the API is designed to allow an arbitrary function to be called, with whatever arguments and keyword arguments that function takes. The user of the API is not necessarily going to remember that the first argument to 'submit' is named 'fn', and that therefore they must jump through special hoops if they should happen to want to submit a function that takes a keyword argument named 'fn'. This becomes especially problematic if the function calling submit is itself accepting an arbitrary callable from a higher layer in the application. If the first argument to submit were named something less common than 'fn', this problem might never have been noticed :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10918] **kwargs unnecessarily restricted in API
Ron Adam ron_a...@users.sourceforge.net added the comment: Is this issue referring to something in Python's library, or a hypothetical function someone may write? If it's in the library, we can look at that case in more detail, otherwise, it's just a bad program design issue and there's nothing to do. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10918] **kwargs unnecessarily restricted in API
New submission from Adrian Dries adr...@gmail.com: An API such as in, e.g. futures: def submit(self, fn, *args, **kwargs): pass cannot be used thus: submit(foo, 1, 2, fn=bar) I can see two options: either mangle the named parameters: def submit(__self, __fn, *args, **kwargs): pass Or fiddle with *args: def submit(*args, **kwargs): self, fn = args[:2] args = args[2:] -- components: Library (Lib) messages: 126367 nosy: avdd priority: normal severity: normal status: open title: **kwargs unnecessarily restricted in API type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10918] **kwargs unnecessarily restricted in API
Changes by Georg Brandl ge...@python.org: -- assignee: - bquinlan nosy: +bquinlan versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com