Re: [Python-Dev] [Python-checkins] cpython (2.7): #14804: Remove [] around optional arguments with default values

On Tue, May 22, 2012 at 6:34 PM, hynek.schlawack <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/a36666c52115 changeset: 77102:a36666c52115 branch: 2.7 parent: 77099:c13066f752a8 user: Hynek Schlawack <hs@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 | ncoghlan@gmail.com | Brisbane, Australia

Hi Nick,
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:
Ah dang, thanks for pointing this out! I went at least five times through all changes but there had to be one thing I missed. :( Same in dl.open() & ossaudiodev.oss_audio_device.setparameters(). I will go through them all once more and fix it at the latest tomorrow. Regards, Hynek
participants (2)
-
Hynek Schlawack
-
Nick Coghlan