[Python-3000] Is this really a SyntaxError?
Guido van Rossum
guido at python.org
Wed Jul 30 05:57:39 CEST 2008
On Tue, Jul 29, 2008 at 6:19 PM, Raymond Hettinger <python at rcn.com> wrote:
>>> With keyword-only parameters allowed now, I think it makes sense to be able
>>> to supply the keywords arguments after the variable length argument as
>>> well.
>>
>> Agreed. I doubt that this will be a simple enough change to allow it
>> in 3.0 though.
>
> Sure would be nice if it could go in. IMO, the functionality is an essential
> companion to keyword-only parameters.
> Looking at the Py2.6 version of the same itertools recipe, the workaround is
> somewhat unattractive:
>
> def grouper(n, iterable, fillvalue=None):
> "grouper(3, 'abcdefg', 'x') --> abc def gxx"
> args = [iter(iterable)] * n
> kwds = dict(fillvalue=fillvalue)
> return izip_longest(*args, **kwds)
If you reverse the two parts it will work:
izip_longest(fillvalue=fillvalue, *args)
This works in 2.6 and 3.0. It would be nice to allow the other order
too, I know it's tripped me up... But the syntax would become really
tricky. So let's strive to fix this for 3.1 rather than introduce
instability in such a subtle area of the code this late in the game.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list