On Tue, 30 Jan 2007 08:19:11 +0100, Jim Jewett email@example.com wrote:
On 1/30/07, Chris Rebert firstname.lastname@example.org wrote:
Also, due to the hairiness/obscurity of the construct, hardly anyone uses it, so the impact of removing it should be relatively minor.
I just did found 181 such uses in my own installation. 29 were either 3rd-party or test code, but that still leaves over 150 uses in the standard library. It is possible that some of them would also work with your semantics, or may even be bugs today -- but you would have to go through them one-by-one as part of the PEP process.
Well, it seems that numbers are gonna be needed anyway to convince people. But that's certainly possible. What exactly did you search for, and what did you find? I did some preliminary grepping through the standardlib myself. regex = "def.*(.*=.*):", searching through all .py files in /Lib: 2455 matches in total in 474 files out of 998 I manually looked through the first bunch of files, those contained 145 matches. (the first files sorted alphabetically up until and including cookielib.py) By far the most of them had literals as default value. A huge amount of them used the =None idiom, I estimate perhaps one third. 10 matches used variables but will not break under the pep's semantics. I found 1 (one) file that used the current semantics to keep state between calls, in two inner functions. This can easily be changed. So, that leaves 145-12=133 uses of default values that are just constants.
If I have time and figure out the right regexes I'll try and come up with some more numbers on the entire stdlib, and the ammount of uses of =None.