Terry Reedy wrote: > "Michele Simionato" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> This is a very relevant question. I would expect the new keyword would >> break lots >> of modules. However measuring is better than speculating. > > Please run also with alternatives, such as 'make'.
I ran a check on my stdlib with 'make' and all I got was: $ count_names.py make "C:\Program Files\Python\Lib" *** C:\Program Files\Python\Lib\site-packages\win32\test\handles.py *** line 73: def make(): line 77: make() Found 2 occurrences of 'make' So it only happens in testing code in the stdlib, which isn't bad breakage-wise as far as I'm concerned. So it looks like 'make' is a much better option. I'll probably update the PEP and the patch to use 'make' soon unless I hear good reasons not to. FWIW, here's what I got with 'create': $ count_names.py create "C:\Program Files\Python\Lib" *** C:\Program Files\Python\Lib\imaplib.py *** line 379: def create(self, mailbox): *** C:\Program Files\Python\Lib\bsddb\dbtables.py *** line 132: def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600, line 140: if create: *** C:\Program Files\Python\Lib\bsddb\test\test_dbtables.py *** line 54: filename='tabletest.db', dbhome=homeDir, create=1) *** C:\Program Files\Python\Lib\distutils\cmd.py *** line 312: def get_finalized_command (self, command, create=1): line 318: cmd_obj = self.distribution.get_command_obj(command, create) *** C:\Program Files\Python\Lib\distutils\dist.py *** line 828: def get_command_obj (self, command, create=1): line 835: if not cmd_obj and create: *** C:\Program Files\Python\Lib\lib-tk\Tkinter.py *** line 1569: self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) *** C:\Program Files\Python\Lib\test\test_mhlib.py *** line 264: def create(n): line 268: create(7) line 269: create(8) line 270: create(9) line 285: create(10) line 286: create(11) line 287: create(12) *** C:\Program Files\Python\Lib\test\test_site.py *** line 75: pth_file.create() line 88: pth_file.create() line 109: def create(self): Found 19 occurrences of 'create' And here's my slightly modified version of Michele's script: import glob import optparse import os import sys import token import tokenize def count_name(name, filename): "Count the occurrences of a Python name in a script" counter = 0 tokens_gen = tokenize.generate_tokens(open(filename).readline) for tok_code, tok_value, (srow, scol), _, line in tokens_gen: if tok_code == token.NAME and tok_value == name: if not counter: print '*** %s ***' % filename counter += 1 print 'line %s: %s' %(srow, line), return counter if __name__ == '__main__': parser = optparse.OptionParser(usage='%prog name dir [dir ...]') options, args = parser.parse_args() try: name = args[0] args[1] # trigger an IndexError if no dirs are provided dirnames = args[1:] except IndexError: parser.error('wrong number of arguments') total = sum(count_name(name, os.path.join(dirpath, filename)) for dirname in dirnames for dirpath, _, filenames in os.walk(dirname) for filename in filenames if filename.endswith('.py')) print 'Found %d occurrences of %r' % (total, name) STeVe -- http://mail.python.org/mailman/listinfo/python-list