On Tue, May 22, 2012 at 6:34 PM, hynek.schlawack
<python-check...@python.org> wrote:
> http://hg.python.org/cpython/rev/a36666c52115
> changeset:   77102:a36666c52115
> branch:      2.7
> parent:      77099:c13066f752a8
> user:        Hynek Schlawack <h...@ox.cx>
> date:        Tue May 22 10:27:40 2012 +0200
> summary:
>  #14804: Remove [] around optional arguments with default values
>
> Mostly just mechanical removal of []. In some rare cases I've pulled the
> default value up into the argument list.

Be a little careful with this - "[]" is the right notation when the
function doesn't support keyword arguments. At least one of the
updated signatures is incorrect:

> diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
> --- a/Doc/library/itertools.rst
> +++ b/Doc/library/itertools.rst
> @@ -627,7 +627,7 @@
>                   break
>
>
> -.. function:: tee(iterable[, n=2])
> +.. function:: tee(iterable, n=2)

>>> itertools.tee([], n=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: tee() takes no keyword arguments

Since calling "tee(itr, n=2)" doesn't add really any clarity over
"tee(itr, 2)", it's unlikely this function will ever gain keyword
argument support (since supporting keyword arguments *is* slower than
supporting only positional arguments for functions written in C.

The change is probably valid for the pure Python modules, and the
builtins looked right, but be wary of any extension modules in the
list.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to