Mercurial > cpython-lru_cache-weakref
annotate Tools/scripts/suff.py @ 17405:afbb65b60fa2 2.0
Inspired by Tim Peters' 1.14->1.15 checkin to asynchat
Quoting orignal message:
'''
Fix from the Madusa mailing list:
http://groups.yahoo.com/group/medusa/message/333
It's clear that Medusa should not be checking for an empty buffer
via "buf is ''". The patch merely changes "is" to "==". However,
there's a mystery here all the same: Python attempts to store null
strings uniquely, so it's unclear why "buf is ''" ever returned
false when buf actually was empty. *Some* string operations produce
non-unique null strings, e.g.
'''
| author | Moshe Zadka <moshez@math.huji.ac.il> |
|---|---|
| date | Wed, 11 Apr 2001 08:06:02 +0000 |
| parents | 73758db2f464 |
| children | 14a27acc755a |
| rev | line source |
|---|---|
|
4573
73758db2f464
/usr/local/bin/python -> /usr/bin/env python
Guido van Rossum <guido@python.org>
parents:
1269
diff
changeset
|
1 #! /usr/bin/env python |
| 274 | 2 |
| 3 # suff | |
| 4 # | |
| 5 # show different suffixes amongst arguments | |
| 6 | |
| 7 import sys | |
| 8 | |
| 9 def main(): | |
| 10 files = sys.argv[1:] | |
| 11 suffixes = {} | |
| 12 for file in files: | |
| 13 suff = getsuffix(file) | |
| 14 if not suffixes.has_key(suff): | |
| 15 suffixes[suff] = [] | |
| 16 suffixes[suff].append(file) | |
| 17 keys = suffixes.keys() | |
| 18 keys.sort() | |
| 19 for suff in keys: | |
| 20 print `suff`, len(suffixes[suff]) | |
| 21 | |
| 22 def getsuffix(file): | |
| 23 suff = '' | |
| 24 for i in range(len(file)): | |
| 559 | 25 if file[i] == '.': |
| 274 | 26 suff = file[i:] |
| 27 return suff | |
| 28 | |
| 29 main() |
