/
usr
/
lib64
/
python2.7
/
/usr/lib64/python2.7
mkdir
upload
Name
Size
Mode
Actions
bsddb/
-
0755
rm
compiler/
-
0755
rm
config/
-
0755
rm
ctypes/
-
0755
rm
curses/
-
0755
rm
distutils/
-
0755
rm
email/
-
0755
rm
encodings/
-
0755
rm
ensurepip/
-
0755
rm
hotshot/
-
0755
rm
idlelib/
-
0755
rm
importlib/
-
0755
rm
json/
-
0755
rm
lib-dynload/
-
0755
rm
lib2to3/
-
0755
rm
logging/
-
0755
rm
multiprocessing/
-
0755
rm
plat-linux2/
-
0755
rm
pydoc_data/
-
0755
rm
site-packages/
-
0755
rm
sqlite3/
-
0755
rm
test/
-
0755
rm
unittest/
-
0755
rm
wsgiref/
-
0755
rm
xml/
-
0755
rm
abc.py
7145
0644
edit
dl
rm
abc.pyc
6143
0644
edit
dl
rm
abc.pyo
6087
0644
edit
dl
rm
aifc.py
34579
0644
edit
dl
rm
aifc.pyc
30459
0644
edit
dl
rm
aifc.pyo
30459
0644
edit
dl
rm
antigravity.py
60
0644
edit
dl
rm
antigravity.pyc
203
0644
edit
dl
rm
antigravity.pyo
203
0644
edit
dl
rm
anydbm.py
2663
0644
edit
dl
rm
anydbm.pyc
2800
0644
edit
dl
rm
anydbm.pyo
2800
0644
edit
dl
rm
argparse.py
89228
0644
edit
dl
rm
argparse.pyc
64367
0644
edit
dl
rm
argparse.pyo
64202
0644
edit
dl
rm
ast.py
11805
0644
edit
dl
rm
ast.pyc
12938
0644
edit
dl
rm
ast.pyo
12938
0644
edit
dl
rm
asynchat.py
11581
0644
edit
dl
rm
asynchat.pyc
8810
0644
edit
dl
rm
asynchat.pyo
8810
0644
edit
dl
rm
asyncore.py
20943
0644
edit
dl
rm
asyncore.pyc
18893
0644
edit
dl
rm
asyncore.pyo
18893
0644
edit
dl
rm
atexit.py
1705
0644
edit
dl
rm
atexit.pyc
2203
0644
edit
dl
rm
atexit.pyo
2203
0644
edit
dl
rm
audiodev.py
7597
0644
edit
dl
rm
audiodev.pyc
8469
0644
edit
dl
rm
audiodev.pyo
8469
0644
edit
dl
rm
base64.py
11806
0755
edit
dl
rm
base64.pyc
11297
0644
edit
dl
rm
base64.pyo
11297
0644
edit
dl
rm
BaseHTTPServer.py
22747
0644
edit
dl
rm
BaseHTTPServer.pyc
21722
0644
edit
dl
rm
BaseHTTPServer.pyo
21722
0644
edit
dl
rm
Bastion.py
5744
0644
edit
dl
rm
Bastion.pyc
6660
0644
edit
dl
rm
Bastion.pyo
6660
0644
edit
dl
rm
bdb.py
21714
0644
edit
dl
rm
bdb.pyc
19101
0644
edit
dl
rm
bdb.pyo
19101
0644
edit
dl
rm
binhex.py
14698
0644
edit
dl
rm
binhex.pyc
15460
0644
edit
dl
rm
binhex.pyo
15460
0644
edit
dl
rm
bisect.py
2595
0644
edit
dl
rm
bisect.pyc
3071
0644
edit
dl
rm
bisect.pyo
3071
0644
edit
dl
rm
calendar.py
23384
0644
edit
dl
rm
calendar.pyc
27913
0644
edit
dl
rm
calendar.pyo
27913
0644
edit
dl
rm
cgi.py
36308
0755
edit
dl
rm
cgi.pyc
33366
0644
edit
dl
rm
cgi.pyo
33366
0644
edit
dl
rm
CGIHTTPServer.py
13089
0644
edit
dl
rm
CGIHTTPServer.pyc
11018
0644
edit
dl
rm
CGIHTTPServer.pyo
11018
0644
edit
dl
rm
cgitb.py
12175
0644
edit
dl
rm
cgitb.pyc
12138
0644
edit
dl
rm
cgitb.pyo
12138
0644
edit
dl
rm
chunk.py
5419
0644
edit
dl
rm
chunk.pyc
5602
0644
edit
dl
rm
chunk.pyo
5602
0644
edit
dl
rm
cmd.py
15026
0644
edit
dl
rm
cmd.pyc
14039
0644
edit
dl
rm
cmd.pyo
14039
0644
edit
dl
rm
code.py
10189
0644
edit
dl
rm
code.pyc
10334
0644
edit
dl
rm
code.pyo
10334
0644
edit
dl
rm
codecs.py
36143
0644
edit
dl
rm
codecs.pyc
36824
0644
edit
dl
rm
codecs.pyo
36824
0644
edit
dl
rm
codeop.py
5999
0644
edit
dl
rm
codeop.pyc
6597
0644
edit
dl
rm
codeop.pyo
6597
0644
edit
dl
rm
collections.py
27798
0644
edit
dl
rm
collections.pyc
26163
0644
edit
dl
rm
collections.pyo
26112
0644
edit
dl
rm
colorsys.py
3691
0644
edit
dl
rm
colorsys.pyc
3991
0644
edit
dl
rm
colorsys.pyo
3991
0644
edit
dl
rm
commands.py
2545
0644
edit
dl
rm
commands.pyc
2469
0644
edit
dl
rm
commands.pyo
2469
0644
edit
dl
rm
compileall.py
7763
0644
edit
dl
rm
compileall.pyc
7017
0644
edit
dl
rm
compileall.pyo
7017
0644
edit
dl
rm
ConfigParser.py
27746
0644
edit
dl
rm
ConfigParser.pyc
25213
0644
edit
dl
rm
ConfigParser.pyo
25213
0644
edit
dl
rm
contextlib.py
4424
0644
edit
dl
rm
contextlib.pyc
4454
0644
edit
dl
rm
contextlib.pyo
4454
0644
edit
dl
rm
Cookie.py
26538
0644
edit
dl
rm
Cookie.pyc
22658
0644
edit
dl
rm
Cookie.pyo
22658
0644
edit
dl
rm
cookielib.py
65486
0644
edit
dl
rm
cookielib.pyc
54725
0644
edit
dl
rm
cookielib.pyo
54537
0644
edit
dl
rm
copy.py
11533
0644
edit
dl
rm
copy.pyc
12170
0644
edit
dl
rm
copy.pyo
12078
0644
edit
dl
rm
copy_reg.py
6974
0644
edit
dl
rm
copy_reg.pyc
5167
0644
edit
dl
rm
copy_reg.pyo
5123
0644
edit
dl
rm
cProfile.py
6573
0755
edit
dl
rm
cProfile.pyc
6395
0644
edit
dl
rm
cProfile.pyo
6395
0644
edit
dl
rm
crypt.py
2292
0644
edit
dl
rm
crypt.pyc
2960
0644
edit
dl
rm
crypt.pyo
2960
0644
edit
dl
rm
csv.py
16708
0644
edit
dl
rm
csv.pyc
13507
0644
edit
dl
rm
csv.pyo
13507
0644
edit
dl
rm
dbhash.py
498
0644
edit
dl
rm
dbhash.pyc
718
0644
edit
dl
rm
dbhash.pyo
718
0644
edit
dl
rm
decimal.py
221933
0644
edit
dl
rm
decimal.pyc
172155
0644
edit
dl
rm
decimal.pyo
172155
0644
edit
dl
rm
difflib.py
82325
0644
edit
dl
rm
difflib.pyc
61898
0644
edit
dl
rm
difflib.pyo
61847
0644
edit
dl
rm
dircache.py
1126
0644
edit
dl
rm
dircache.pyc
1576
0644
edit
dl
rm
dircache.pyo
1576
0644
edit
dl
rm
dis.py
6499
0644
edit
dl
rm
dis.pyc
6228
0644
edit
dl
rm
dis.pyo
6228
0644
edit
dl
rm
doctest.py
105095
0644
edit
dl
rm
doctest.pyc
83637
0644
edit
dl
rm
doctest.pyo
83350
0644
edit
dl
rm
DocXMLRPCServer.py
10768
0644
edit
dl
rm
DocXMLRPCServer.pyc
10195
0644
edit
dl
rm
DocXMLRPCServer.pyo
10086
0644
edit
dl
rm
dumbdbm.py
9141
0644
edit
dl
rm
dumbdbm.pyc
6746
0644
edit
dl
rm
dumbdbm.pyo
6746
0644
edit
dl
rm
dummy_thread.py
4418
0644
edit
dl
rm
dummy_thread.pyc
5394
0644
edit
dl
rm
dummy_thread.pyo
5394
0644
edit
dl
rm
dummy_threading.py
2804
0644
edit
dl
rm
dummy_threading.pyc
1285
0644
edit
dl
rm
dummy_threading.pyo
1285
0644
edit
dl
rm
filecmp.py
9588
0644
edit
dl
rm
filecmp.pyc
9622
0644
edit
dl
rm
filecmp.pyo
9622
0644
edit
dl
rm
fileinput.py
13746
0644
edit
dl
rm
fileinput.pyc
14500
0644
edit
dl
rm
fileinput.pyo
14500
0644
edit
dl
rm
fnmatch.py
3315
0644
edit
dl
rm
fnmatch.pyc
3614
0644
edit
dl
rm
fnmatch.pyo
3614
0644
edit
dl
rm
formatter.py
14911
0644
edit
dl
rm
formatter.pyc
19178
0644
edit
dl
rm
formatter.pyo
19178
0644
edit
dl
rm
fpformat.py
4732
0644
edit
dl
rm
fpformat.pyc
4703
0644
edit
dl
rm
fpformat.pyo
4703
0644
edit
dl
rm
fractions.py
22390
0644
edit
dl
rm
fractions.pyc
19711
0644
edit
dl
rm
fractions.pyo
19711
0644
edit
dl
rm
ftplib.py
38555
0644
edit
dl
rm
ftplib.pyc
34939
0644
edit
dl
rm
ftplib.pyo
34939
0644
edit
dl
rm
functools.py
4806
0644
edit
dl
rm
functools.pyc
6629
0644
edit
dl
rm
functools.pyo
6629
0644
edit
dl
rm
genericpath.py
3201
0644
edit
dl
rm
genericpath.pyc
3517
0644
edit
dl
rm
genericpath.pyo
3517
0644
edit
dl
rm
getopt.py
7319
0644
edit
dl
rm
getopt.pyc
6654
0644
edit
dl
rm
getopt.pyo
6609
0644
edit
dl
rm
getpass.py
5563
0644
edit
dl
rm
getpass.pyc
4744
0644
edit
dl
rm
getpass.pyo
4744
0644
edit
dl
rm
gettext.py
22666
0644
edit
dl
rm
gettext.pyc
18004
0644
edit
dl
rm
gettext.pyo
18004
0644
edit
dl
rm
glob.py
3114
0644
edit
dl
rm
glob.pyc
2943
0644
edit
dl
rm
glob.pyo
2943
0644
edit
dl
rm
gzip.py
19028
0644
edit
dl
rm
gzip.pyc
15236
0644
edit
dl
rm
gzip.pyo
15236
0644
edit
dl
rm
hashlib.py
7841
0644
edit
dl
rm
hashlib.pyc
6919
0644
edit
dl
rm
hashlib.pyo
6919
0644
edit
dl
rm
heapq.py
18295
0644
edit
dl
rm
heapq.pyc
14564
0644
edit
dl
rm
heapq.pyo
14564
0644
edit
dl
rm
hmac.py
4588
0644
edit
dl
rm
hmac.pyc
4542
0644
edit
dl
rm
hmac.pyo
4542
0644
edit
dl
rm
htmlentitydefs.py
18056
0644
edit
dl
rm
htmlentitydefs.pyc
6367
0644
edit
dl
rm
htmlentitydefs.pyo
6367
0644
edit
dl
rm
htmllib.py
12869
0644
edit
dl
rm
htmllib.pyc
20309
0644
edit
dl
rm
htmllib.pyo
20309
0644
edit
dl
rm
HTMLParser.py
17171
0644
edit
dl
rm
HTMLParser.pyc
13727
0644
edit
dl
rm
HTMLParser.pyo
13422
0644
edit
dl
rm
httplib.py
53306
0644
edit
dl
rm
httplib.pyc
38724
0644
edit
dl
rm
httplib.pyo
38540
0644
edit
dl
rm
ihooks.py
18986
0644
edit
dl
rm
ihooks.pyc
21372
0644
edit
dl
rm
ihooks.pyo
21372
0644
edit
dl
rm
imaplib.py
48366
0644
edit
dl
rm
imaplib.pyc
45011
0644
edit
dl
rm
imaplib.pyo
42310
0644
edit
dl
rm
imghdr.py
3541
0644
edit
dl
rm
imghdr.pyc
4838
0644
edit
dl
rm
imghdr.pyo
4838
0644
edit
dl
rm
imputil.py
25764
0644
edit
dl
rm
imputil.pyc
15623
0644
edit
dl
rm
imputil.pyo
15445
0644
edit
dl
rm
inspect.py
43008
0644
edit
dl
rm
inspect.pyc
40229
0644
edit
dl
rm
inspect.pyo
40229
0644
edit
dl
rm
io.py
3322
0644
edit
dl
rm
io.pyc
3589
0644
edit
dl
rm
io.pyo
3589
0644
edit
dl
rm
keyword.py
1995
0755
edit
dl
rm
keyword.pyc
2105
0644
edit
dl
rm
keyword.pyo
2105
0644
edit
dl
rm
linecache.py
4027
0644
edit
dl
rm
linecache.pyc
3272
0644
edit
dl
rm
linecache.pyo
3272
0644
edit
dl
rm
locale.py
102834
0644
edit
dl
rm
locale.pyc
56610
0644
edit
dl
rm
locale.pyo
56610
0644
edit
dl
rm
macpath.py
6289
0644
edit
dl
rm
macpath.pyc
7681
0644
edit
dl
rm
macpath.pyo
7681
0644
edit
dl
rm
macurl2path.py
2731
0644
edit
dl
rm
macurl2path.pyc
2244
0644
edit
dl
rm
macurl2path.pyo
2244
0644
edit
dl
rm
mailbox.py
81240
0644
edit
dl
rm
mailbox.pyc
76717
0644
edit
dl
rm
mailbox.pyo
76670
0644
edit
dl
rm
mailcap.py
8404
0644
edit
dl
rm
mailcap.pyc
7955
0644
edit
dl
rm
mailcap.pyo
7955
0644
edit
dl
rm
markupbase.py
14643
0644
edit
dl
rm
markupbase.pyc
9267
0644
edit
dl
rm
markupbase.pyo
9071
0644
edit
dl
rm
md5.py
358
0644
edit
dl
rm
md5.pyc
378
0644
edit
dl
rm
md5.pyo
378
0644
edit
dl
rm
mhlib.py
33434
0644
edit
dl
rm
mhlib.pyc
33777
0644
edit
dl
rm
mhlib.pyo
33777
0644
edit
dl
rm
mimetools.py
7168
0644
edit
dl
rm
mimetools.pyc
8201
0644
edit
dl
rm
mimetools.pyo
8201
0644
edit
dl
rm
mimetypes.py
21028
0644
edit
dl
rm
mimetypes.pyc
18489
0644
edit
dl
rm
mimetypes.pyo
18489
0644
edit
dl
rm
MimeWriter.py
6482
0644
edit
dl
rm
MimeWriter.pyc
7364
0644
edit
dl
rm
MimeWriter.pyo
7364
0644
edit
dl
rm
mimify.py
15020
0755
edit
dl
rm
mimify.pyc
12001
0644
edit
dl
rm
mimify.pyo
12001
0644
edit
dl
rm
modulefinder.py
24461
0644
edit
dl
rm
modulefinder.pyc
19127
0644
edit
dl
rm
modulefinder.pyo
19045
0644
edit
dl
rm
multifile.py
4820
0644
edit
dl
rm
multifile.pyc
5420
0644
edit
dl
rm
multifile.pyo
5378
0644
edit
dl
rm
mutex.py
1878
0644
edit
dl
rm
mutex.pyc
2516
0644
edit
dl
rm
mutex.pyo
2516
0644
edit
dl
rm
netrc.py
5888
0644
edit
dl
rm
netrc.pyc
4714
0644
edit
dl
rm
netrc.pyo
4714
0644
edit
dl
rm
new.py
610
0644
edit
dl
rm
new.pyc
862
0644
edit
dl
rm
new.pyo
862
0644
edit
dl
rm
nntplib.py
21470
0644
edit
dl
rm
nntplib.pyc
21044
0644
edit
dl
rm
nntplib.pyo
21044
0644
edit
dl
rm
ntpath.py
19429
0644
edit
dl
rm
ntpath.pyc
13129
0644
edit
dl
rm
ntpath.pyo
13129
0644
edit
dl
rm
nturl2path.py
2419
0644
edit
dl
rm
nturl2path.pyc
1815
0644
edit
dl
rm
nturl2path.pyo
1815
0644
edit
dl
rm
numbers.py
10319
0644
edit
dl
rm
numbers.pyc
14012
0644
edit
dl
rm
numbers.pyo
14012
0644
edit
dl
rm
opcode.py
5474
0644
edit
dl
rm
opcode.pyc
6145
0644
edit
dl
rm
opcode.pyo
6145
0644
edit
dl
rm
optparse.py
61203
0644
edit
dl
rm
optparse.pyc
53894
0644
edit
dl
rm
optparse.pyo
53811
0644
edit
dl
rm
os.py
25910
0644
edit
dl
rm
os.pyc
25689
0644
edit
dl
rm
os.pyo
25689
0644
edit
dl
rm
os2emxpath.py
4635
0644
edit
dl
rm
os2emxpath.pyc
4525
0644
edit
dl
rm
os2emxpath.pyo
4525
0644
edit
dl
rm
pdb.doc
7914
0644
edit
dl
rm
pdb.py
46098
0755
edit
dl
rm
pdb.pyc
43669
0644
edit
dl
rm
pdb.pyo
43669
0644
edit
dl
rm
pickle.py
45489
0644
edit
dl
rm
pickle.pyc
38560
0644
edit
dl
rm
pickle.pyo
38364
0644
edit
dl
rm
pickletools.py
74523
0644
edit
dl
rm
pickletools.pyc
57032
0644
edit
dl
rm
pickletools.pyo
56171
0644
edit
dl
rm
pipes.py
9582
0644
edit
dl
rm
pipes.pyc
9308
0644
edit
dl
rm
pipes.pyo
9308
0644
edit
dl
rm
pkgutil.py
20243
0644
edit
dl
rm
pkgutil.pyc
18959
0644
edit
dl
rm
pkgutil.pyo
18959
0644
edit
dl
rm
platform.py
52801
0755
edit
dl
rm
platform.pyc
37971
0644
edit
dl
rm
platform.pyo
37971
0644
edit
dl
rm
plistlib.py
15810
0644
edit
dl
rm
plistlib.pyc
19963
0644
edit
dl
rm
plistlib.pyo
19877
0644
edit
dl
rm
popen2.py
8416
0644
edit
dl
rm
popen2.pyc
9025
0644
edit
dl
rm
popen2.pyo
8983
0644
edit
dl
rm
poplib.py
12824
0644
edit
dl
rm
poplib.pyc
13345
0644
edit
dl
rm
poplib.pyo
13345
0644
edit
dl
rm
posixfile.py
8003
0644
edit
dl
rm
posixfile.pyc
7652
0644
edit
dl
rm
posixfile.pyo
7652
0644
edit
dl
rm
posixpath.py
14293
0644
edit
dl
rm
posixpath.pyc
11462
0644
edit
dl
rm
posixpath.pyo
11462
0644
edit
dl
rm
pprint.py
11777
0644
edit
dl
rm
pprint.pyc
10194
0644
edit
dl
rm
pprint.pyo
10017
0644
edit
dl
rm
profile.py
22781
0755
edit
dl
rm
profile.pyc
16456
0644
edit
dl
rm
profile.pyo
16209
0644
edit
dl
rm
pstats.py
26712
0644
edit
dl
rm
pstats.pyc
25013
0644
edit
dl
rm
pstats.pyo
25013
0644
edit
dl
rm
pty.py
5058
0644
edit
dl
rm
pty.pyc
4966
0644
edit
dl
rm
pty.pyo
4966
0644
edit
dl
rm
pyclbr.py
13388
0644
edit
dl
rm
pyclbr.pyc
9651
0644
edit
dl
rm
pyclbr.pyo
9651
0644
edit
dl
rm
pydoc.py
95739
0755
edit
dl
rm
pydoc.pyc
92342
0644
edit
dl
rm
pydoc.pyo
92278
0644
edit
dl
rm
py_compile.py
5936
0644
edit
dl
rm
py_compile.pyc
6428
0644
edit
dl
rm
py_compile.pyo
6428
0644
edit
dl
rm
Queue.py
8577
0644
edit
dl
rm
Queue.pyc
9424
0644
edit
dl
rm
Queue.pyo
9424
0644
edit
dl
rm
quopri.py
6968
0755
edit
dl
rm
quopri.pyc
6574
0644
edit
dl
rm
quopri.pyo
6574
0644
edit
dl
rm
random.py
32457
0644
edit
dl
rm
random.pyc
25704
0644
edit
dl
rm
random.pyo
25704
0644
edit
dl
rm
re.py
13423
0644
edit
dl
rm
re.pyc
13413
0644
edit
dl
rm
re.pyo
13413
0644
edit
dl
rm
repr.py
4296
0644
edit
dl
rm
repr.pyc
5385
0644
edit
dl
rm
repr.pyo
5385
0644
edit
dl
rm
rexec.py
20148
0644
edit
dl
rm
rexec.pyc
23807
0644
edit
dl
rm
rexec.pyo
23807
0644
edit
dl
rm
rfc822.py
33542
0644
edit
dl
rm
rfc822.pyc
31813
0644
edit
dl
rm
rfc822.pyo
31813
0644
edit
dl
rm
rlcompleter.py
5991
0644
edit
dl
rm
rlcompleter.pyc
6078
0644
edit
dl
rm
rlcompleter.pyo
6078
0644
edit
dl
rm
robotparser.py
7695
0644
edit
dl
rm
robotparser.pyc
8003
0644
edit
dl
rm
robotparser.pyo
8003
0644
edit
dl
rm
runpy.py
11081
0644
edit
dl
rm
runpy.pyc
8803
0644
edit
dl
rm
runpy.pyo
8803
0644
edit
dl
rm
sched.py
5088
0644
edit
dl
rm
sched.pyc
4994
0644
edit
dl
rm
sched.pyo
4994
0644
edit
dl
rm
sets.py
19050
0644
edit
dl
rm
sets.pyc
16895
0644
edit
dl
rm
sets.pyo
16895
0644
edit
dl
rm
sgmllib.py
17884
0644
edit
dl
rm
sgmllib.pyc
15436
0644
edit
dl
rm
sgmllib.pyo
15436
0644
edit
dl
rm
sha.py
393
0644
edit
dl
rm
sha.pyc
421
0644
edit
dl
rm
sha.pyo
421
0644
edit
dl
rm
shelve.py
8178
0644
edit
dl
rm
shelve.pyc
10256
0644
edit
dl
rm
shelve.pyo
10256
0644
edit
dl
rm
shlex.py
11164
0644
edit
dl
rm
shlex.pyc
7558
0644
edit
dl
rm
shlex.pyo
7558
0644
edit
dl
rm
shutil.py
19871
0644
edit
dl
rm
shutil.pyc
19259
0644
edit
dl
rm
shutil.pyo
19259
0644
edit
dl
rm
SimpleHTTPServer.py
7997
0644
edit
dl
rm
SimpleHTTPServer.pyc
8010
0644
edit
dl
rm
SimpleHTTPServer.pyo
8010
0644
edit
dl
rm
SimpleXMLRPCServer.py
25812
0644
edit
dl
rm
SimpleXMLRPCServer.pyc
22863
0644
edit
dl
rm
SimpleXMLRPCServer.pyo
22863
0644
edit
dl
rm
site.py
21296
0644
edit
dl
rm
site.pyc
20786
0644
edit
dl
rm
site.pyo
20786
0644
edit
dl
rm
smtpd.py
18542
0755
edit
dl
rm
smtpd.pyc
15883
0644
edit
dl
rm
smtpd.pyo
15883
0644
edit
dl
rm
smtplib.py
32134
0755
edit
dl
rm
smtplib.pyc
30304
0644
edit
dl
rm
smtplib.pyo
30304
0644
edit
dl
rm
sndhdr.py
5973
0644
edit
dl
rm
sndhdr.pyc
7361
0644
edit
dl
rm
sndhdr.pyo
7361
0644
edit
dl
rm
socket.py
20615
0644
edit
dl
rm
socket.pyc
16152
0644
edit
dl
rm
socket.pyo
16066
0644
edit
dl
rm
SocketServer.py
23948
0644
edit
dl
rm
SocketServer.pyc
24087
0644
edit
dl
rm
SocketServer.pyo
24087
0644
edit
dl
rm
sre.py
384
0644
edit
dl
rm
sre.pyc
519
0644
edit
dl
rm
sre.pyo
519
0644
edit
dl
rm
sre_compile.py
19823
0644
edit
dl
rm
sre_compile.pyc
12560
0644
edit
dl
rm
sre_compile.pyo
12404
0644
edit
dl
rm
sre_constants.py
7197
0644
edit
dl
rm
sre_constants.pyc
6195
0644
edit
dl
rm
sre_constants.pyo
6195
0644
edit
dl
rm
sre_parse.py
30700
0644
edit
dl
rm
sre_parse.pyc
21156
0644
edit
dl
rm
sre_parse.pyo
21156
0644
edit
dl
rm
ssl.py
39310
0644
edit
dl
rm
ssl.pyc
32716
0644
edit
dl
rm
ssl.pyo
32716
0644
edit
dl
rm
stat.py
1842
0644
edit
dl
rm
stat.pyc
2751
0644
edit
dl
rm
stat.pyo
2751
0644
edit
dl
rm
statvfs.py
898
0644
edit
dl
rm
statvfs.pyc
620
0644
edit
dl
rm
statvfs.pyo
620
0644
edit
dl
rm
string.py
21548
0644
edit
dl
rm
string.pyc
20459
0644
edit
dl
rm
string.pyo
20459
0644
edit
dl
rm
StringIO.py
10662
0644
edit
dl
rm
StringIO.pyc
11480
0644
edit
dl
rm
StringIO.pyo
11480
0644
edit
dl
rm
stringold.py
12449
0644
edit
dl
rm
stringold.pyc
12549
0644
edit
dl
rm
stringold.pyo
12549
0644
edit
dl
rm
stringprep.py
13522
0644
edit
dl
rm
stringprep.pyc
14487
0644
edit
dl
rm
stringprep.pyo
14415
0644
edit
dl
rm
struct.py
82
0644
edit
dl
rm
struct.pyc
239
0644
edit
dl
rm
struct.pyo
239
0644
edit
dl
rm
subprocess.py
50520
0644
edit
dl
rm
subprocess.pyc
32398
0644
edit
dl
rm
subprocess.pyo
32398
0644
edit
dl
rm
sunau.py
17222
0644
edit
dl
rm
sunau.pyc
18394
0644
edit
dl
rm
sunau.pyo
18394
0644
edit
dl
rm
sunaudio.py
1399
0644
edit
dl
rm
sunaudio.pyc
1987
0644
edit
dl
rm
sunaudio.pyo
1987
0644
edit
dl
rm
symbol.py
2057
0755
edit
dl
rm
symbol.pyc
3026
0644
edit
dl
rm
symbol.pyo
3026
0644
edit
dl
rm
symtable.py
7437
0644
edit
dl
rm
symtable.pyc
11786
0644
edit
dl
rm
symtable.pyo
11655
0644
edit
dl
rm
sysconfig.py
22852
0644
edit
dl
rm
sysconfig.pyc
17818
0644
edit
dl
rm
sysconfig.pyo
17818
0644
edit
dl
rm
tabnanny.py
11339
0755
edit
dl
rm
tabnanny.pyc
8247
0644
edit
dl
rm
tabnanny.pyo
8247
0644
edit
dl
rm
tarfile.py
90655
0644
edit
dl
rm
tarfile.pyc
76193
0644
edit
dl
rm
tarfile.pyo
76193
0644
edit
dl
rm
telnetlib.py
27036
0644
edit
dl
rm
telnetlib.pyc
23154
0644
edit
dl
rm
telnetlib.pyo
23154
0644
edit
dl
rm
tempfile.py
19547
0644
edit
dl
rm
tempfile.pyc
20344
0644
edit
dl
rm
tempfile.pyo
20344
0644
edit
dl
rm
textwrap.py
17280
0644
edit
dl
rm
textwrap.pyc
12097
0644
edit
dl
rm
textwrap.pyo
12005
0644
edit
dl
rm
this.py
1002
0644
edit
dl
rm
this.pyc
1220
0644
edit
dl
rm
this.pyo
1220
0644
edit
dl
rm
threading.py
47377
0644
edit
dl
rm
threading.pyc
42726
0644
edit
dl
rm
threading.pyo
40552
0644
edit
dl
rm
timeit.py
12791
0755
edit
dl
rm
timeit.pyc
12183
0644
edit
dl
rm
timeit.pyo
12183
0644
edit
dl
rm
toaiff.py
3142
0644
edit
dl
rm
toaiff.pyc
3106
0644
edit
dl
rm
toaiff.pyo
3106
0644
edit
dl
rm
token.py
2922
0644
edit
dl
rm
token.pyc
3816
0644
edit
dl
rm
token.pyo
3816
0644
edit
dl
rm
tokenize.py
17483
0644
edit
dl
rm
tokenize.pyc
14505
0644
edit
dl
rm
tokenize.pyo
14449
0644
edit
dl
rm
trace.py
29891
0755
edit
dl
rm
trace.pyc
22793
0644
edit
dl
rm
trace.pyo
22730
0644
edit
dl
rm
traceback.py
11285
0644
edit
dl
rm
traceback.pyc
11679
0644
edit
dl
rm
traceback.pyo
11679
0644
edit
dl
rm
tty.py
879
0644
edit
dl
rm
tty.pyc
1317
0644
edit
dl
rm
tty.pyo
1317
0644
edit
dl
rm
types.py
2094
0644
edit
dl
rm
types.pyc
2725
0644
edit
dl
rm
types.pyo
2725
0644
edit
dl
rm
urllib.py
60228
0644
edit
dl
rm
urllib.pyc
51241
0644
edit
dl
rm
urllib.pyo
51146
0644
edit
dl
rm
urllib2.py
52541
0644
edit
dl
rm
urllib2.pyc
47302
0644
edit
dl
rm
urllib2.pyo
47207
0644
edit
dl
rm
urlparse.py
20461
0644
edit
dl
rm
urlparse.pyc
18015
0644
edit
dl
rm
urlparse.pyo
18015
0644
edit
dl
rm
user.py
1627
0644
edit
dl
rm
user.pyc
1724
0644
edit
dl
rm
user.pyo
1724
0644
edit
dl
rm
UserDict.py
7060
0644
edit
dl
rm
UserDict.pyc
9711
0644
edit
dl
rm
UserDict.pyo
9711
0644
edit
dl
rm
UserList.py
3644
0644
edit
dl
rm
UserList.pyc
6577
0644
edit
dl
rm
UserList.pyo
6577
0644
edit
dl
rm
UserString.py
9687
0755
edit
dl
rm
UserString.pyc
14864
0644
edit
dl
rm
UserString.pyo
14864
0644
edit
dl
rm
uu.py
6697
0755
edit
dl
rm
uu.pyc
4390
0644
edit
dl
rm
uu.pyo
4390
0644
edit
dl
rm
uuid.py
23530
0644
edit
dl
rm
uuid.pyc
23366
0644
edit
dl
rm
uuid.pyo
23250
0644
edit
dl
rm
warnings.py
14823
0644
edit
dl
rm
warnings.pyc
13510
0644
edit
dl
rm
warnings.pyo
12721
0644
edit
dl
rm
wave.py
18582
0644
edit
dl
rm
wave.pyc
20013
0644
edit
dl
rm
wave.pyo
19869
0644
edit
dl
rm
weakref.py
14830
0644
edit
dl
rm
weakref.pyc
16441
0644
edit
dl
rm
weakref.pyo
16441
0644
edit
dl
rm
webbrowser.py
22725
0755
edit
dl
rm
webbrowser.pyc
19750
0644
edit
dl
rm
webbrowser.pyo
19705
0644
edit
dl
rm
whichdb.py
3379
0644
edit
dl
rm
whichdb.pyc
2241
0644
edit
dl
rm
whichdb.pyo
2241
0644
edit
dl
rm
wsgiref.egg-info
187
0644
edit
dl
rm
xdrlib.py
6069
0644
edit
dl
rm
xdrlib.pyc
9902
0644
edit
dl
rm
xdrlib.pyo
9902
0644
edit
dl
rm
xmllib.py
34865
0644
edit
dl
rm
xmllib.pyc
26848
0644
edit
dl
rm
xmllib.pyo
26848
0644
edit
dl
rm
xmlrpclib.py
52136
0644
edit
dl
rm
xmlrpclib.pyc
44106
0644
edit
dl
rm
xmlrpclib.pyo
43922
0644
edit
dl
rm
zipfile.py
59477
0644
edit
dl
rm
zipfile.pyc
42137
0644
edit
dl
rm
zipfile.pyo
42137
0644
edit
dl
rm
_abcoll.py
18619
0644
edit
dl
rm
_abcoll.pyc
25682
0644
edit
dl
rm
_abcoll.pyo
25682
0644
edit
dl
rm
_LWPCookieJar.py
6553
0644
edit
dl
rm
_LWPCookieJar.pyc
5434
0644
edit
dl
rm
_LWPCookieJar.pyo
5434
0644
edit
dl
rm
_MozillaCookieJar.py
5797
0644
edit
dl
rm
_MozillaCookieJar.pyc
4461
0644
edit
dl
rm
_MozillaCookieJar.pyo
4422
0644
edit
dl
rm
_osx_support.py
19100
0644
edit
dl
rm
_osx_support.pyc
11758
0644
edit
dl
rm
_osx_support.pyo
11758
0644
edit
dl
rm
_pyio.py
69630
0644
edit
dl
rm
_pyio.pyc
64701
0644
edit
dl
rm
_pyio.pyo
64701
0644
edit
dl
rm
_strptime.py
20728
0644
edit
dl
rm
_strptime.pyc
15172
0644
edit
dl
rm
_strptime.pyo
15172
0644
edit
dl
rm
_sysconfigdata.py
19732
0644
edit
dl
rm
_sysconfigdata.pyc
22968
0644
edit
dl
rm
_sysconfigdata.pyo
22968
0644
edit
dl
rm
_threading_local.py
7260
0644
edit
dl
rm
_threading_local.pyc
6373
0644
edit
dl
rm
_threading_local.pyo
6373
0644
edit
dl
rm
_weakrefset.py
5911
0644
edit
dl
rm
_weakrefset.pyc
9678
0644
edit
dl
rm
_weakrefset.pyo
9678
0644
edit
dl
rm
__future__.py
4380
0644
edit
dl
rm
__future__.pyc
4223
0644
edit
dl
rm
__future__.pyo
4223
0644
edit
dl
rm
__phello__.foo.py
64
0644
edit
dl
rm
__phello__.foo.pyc
125
0644
edit
dl
rm
__phello__.foo.pyo
125
0644
edit
dl
rm
Edit:
/usr/lib64/python2.7/collections.py
(27798B)
'''This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, dict, list, set, and tuple. * namedtuple factory function for creating tuple subclasses with named fields * deque list-like container with fast appends and pops on either end * Counter dict subclass for counting hashable objects * OrderedDict dict subclass that remembers the order entries were added * defaultdict dict subclass that calls a factory function to supply missing values ''' __all__ = ['Counter', 'deque', 'defaultdict', 'namedtuple', 'OrderedDict'] # For bootstrapping reasons, the collection ABCs are defined in _abcoll.py. # They should however be considered an integral part of collections.py. from _abcoll import * import _abcoll __all__ += _abcoll.__all__ from _collections import deque, defaultdict from operator import itemgetter as _itemgetter, eq as _eq from keyword import iskeyword as _iskeyword import sys as _sys import heapq as _heapq from itertools import repeat as _repeat, chain as _chain, starmap as _starmap from itertools import imap as _imap try: from thread import get_ident as _get_ident except ImportError: from dummy_thread import get_ident as _get_ident ################################################################################ ### OrderedDict ################################################################################ class OrderedDict(dict): 'Dictionary that remembers insertion order' # An inherited dict maps keys to values. # The inherited dict provides __getitem__, __len__, __contains__, and get. # The remaining methods are order-aware. # Big-O running times for all methods are the same as regular dictionaries. # The internal self.__map dict maps keys to links in a doubly linked list. # The circular doubly linked list starts and ends with a sentinel element. # The sentinel element never gets deleted (this simplifies the algorithm). # Each link is stored as a list of length three: [PREV, NEXT, KEY]. def __init__(*args, **kwds): '''Initialize an ordered dictionary. The signature is the same as regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary. ''' if not args: raise TypeError("descriptor '__init__' of 'OrderedDict' object " "needs an argument") self = args[0] args = args[1:] if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) try: self.__root except AttributeError: self.__root = root = [] # sentinel node root[:] = [root, root, None] self.__map = {} self.__update(*args, **kwds) def __setitem__(self, key, value, dict_setitem=dict.__setitem__): 'od.__setitem__(i, y) <==> od[i]=y' # Setting a new item creates a new link at the end of the linked list, # and the inherited dictionary is updated with the new key/value pair. if key not in self: root = self.__root last = root[0] last[1] = root[0] = self.__map[key] = [last, root, key] return dict_setitem(self, key, value) def __delitem__(self, key, dict_delitem=dict.__delitem__): 'od.__delitem__(y) <==> del od[y]' # Deleting an existing item uses self.__map to find the link which gets # removed by updating the links in the predecessor and successor nodes. dict_delitem(self, key) link_prev, link_next, _ = self.__map.pop(key) link_prev[1] = link_next # update link_prev[NEXT] link_next[0] = link_prev # update link_next[PREV] def __iter__(self): 'od.__iter__() <==> iter(od)' # Traverse the linked list in order. root = self.__root curr = root[1] # start at the first node while curr is not root: yield curr[2] # yield the curr[KEY] curr = curr[1] # move to next node def __reversed__(self): 'od.__reversed__() <==> reversed(od)' # Traverse the linked list in reverse order. root = self.__root curr = root[0] # start at the last node while curr is not root: yield curr[2] # yield the curr[KEY] curr = curr[0] # move to previous node def clear(self): 'od.clear() -> None. Remove all items from od.' root = self.__root root[:] = [root, root, None] self.__map.clear() dict.clear(self) # -- the following methods do not depend on the internal structure -- def keys(self): 'od.keys() -> list of keys in od' return list(self) def values(self): 'od.values() -> list of values in od' return [self[key] for key in self] def items(self): 'od.items() -> list of (key, value) pairs in od' return [(key, self[key]) for key in self] def iterkeys(self): 'od.iterkeys() -> an iterator over the keys in od' return iter(self) def itervalues(self): 'od.itervalues -> an iterator over the values in od' for k in self: yield self[k] def iteritems(self): 'od.iteritems -> an iterator over the (key, value) pairs in od' for k in self: yield (k, self[k]) update = MutableMapping.update __update = update # let subclasses override update without breaking __init__ __marker = object() def pop(self, key, default=__marker): '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. ''' if key in self: result = self[key] del self[key] return result if default is self.__marker: raise KeyError(key) return default def setdefault(self, key, default=None): 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od' if key in self: return self[key] self[key] = default return default def popitem(self, last=True): '''od.popitem() -> (k, v), return and remove a (key, value) pair. Pairs are returned in LIFO order if last is true or FIFO order if false. ''' if not self: raise KeyError('dictionary is empty') key = next(reversed(self) if last else iter(self)) value = self.pop(key) return key, value def __repr__(self, _repr_running={}): 'od.__repr__() <==> repr(od)' call_key = id(self), _get_ident() if call_key in _repr_running: return '...' _repr_running[call_key] = 1 try: if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, self.items()) finally: del _repr_running[call_key] def __reduce__(self): 'Return state information for pickling' items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() for k in vars(OrderedDict()): inst_dict.pop(k, None) if inst_dict: return (self.__class__, (items,), inst_dict) return self.__class__, (items,) def copy(self): 'od.copy() -> a shallow copy of od' return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S. If not specified, the value defaults to None. ''' self = cls() for key in iterable: self[key] = value return self def __eq__(self, other): '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ''' if isinstance(other, OrderedDict): return dict.__eq__(self, other) and all(_imap(_eq, self, other)) return dict.__eq__(self, other) def __ne__(self, other): 'od.__ne__(y) <==> od!=y' return not self == other # -- the following methods support python 3.x style dictionary views -- def viewkeys(self): "od.viewkeys() -> a set-like object providing a view on od's keys" return KeysView(self) def viewvalues(self): "od.viewvalues() -> an object providing a view on od's values" return ValuesView(self) def viewitems(self): "od.viewitems() -> a set-like object providing a view on od's items" return ItemsView(self) ################################################################################ ### namedtuple ################################################################################ _class_template = '''\ class {typename}(tuple): '{typename}({arg_list})' __slots__ = () _fields = {field_names!r} def __new__(_cls, {arg_list}): 'Create new instance of {typename}({arg_list})' return _tuple.__new__(_cls, ({arg_list})) @classmethod def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new {typename} object from a sequence or iterable' result = new(cls, iterable) if len(result) != {num_fields:d}: raise TypeError('Expected {num_fields:d} arguments, got %d' % len(result)) return result def __repr__(self): 'Return a nicely formatted representation string' return '{typename}({repr_fmt})' % self def _asdict(self): 'Return a new OrderedDict which maps field names to their values' return OrderedDict(zip(self._fields, self)) def _replace(_self, **kwds): 'Return a new {typename} object replacing specified fields with new values' result = _self._make(map(kwds.pop, {field_names!r}, _self)) if kwds: raise ValueError('Got unexpected field names: %r' % kwds.keys()) return result def __getnewargs__(self): 'Return self as a plain tuple. Used by copy and pickle.' return tuple(self) __dict__ = _property(_asdict) def __getstate__(self): 'Exclude the OrderedDict from pickling' pass {field_defs} ''' _repr_template = '{name}=%r' _field_template = '''\ {name} = _property(_itemgetter({index:d}), doc='Alias for field number {index:d}') ''' def namedtuple(typename, field_names, verbose=False, rename=False): """Returns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) """ # Validate the field names. At the user's option, either generate an error # message or automatically replace the field name with a valid name. if isinstance(field_names, basestring): field_names = field_names.replace(',', ' ').split() field_names = map(str, field_names) typename = str(typename) if rename: seen = set() for index, name in enumerate(field_names): if (not all(c.isalnum() or c=='_' for c in name) or _iskeyword(name) or not name or name[0].isdigit() or name.startswith('_') or name in seen): field_names[index] = '_%d' % index seen.add(name) for name in [typename] + field_names: if type(name) != str: raise TypeError('Type names and field names must be strings') if not all(c.isalnum() or c=='_' for c in name): raise ValueError('Type names and field names can only contain ' 'alphanumeric characters and underscores: %r' % name) if _iskeyword(name): raise ValueError('Type names and field names cannot be a ' 'keyword: %r' % name) if name[0].isdigit(): raise ValueError('Type names and field names cannot start with ' 'a number: %r' % name) seen = set() for name in field_names: if name.startswith('_') and not rename: raise ValueError('Field names cannot start with an underscore: ' '%r' % name) if name in seen: raise ValueError('Encountered duplicate field name: %r' % name) seen.add(name) # Fill-in the class template class_definition = _class_template.format( typename = typename, field_names = tuple(field_names), num_fields = len(field_names), arg_list = repr(tuple(field_names)).replace("'", "")[1:-1], repr_fmt = ', '.join(_repr_template.format(name=name) for name in field_names), field_defs = '\n'.join(_field_template.format(index=index, name=name) for index, name in enumerate(field_names)) ) if verbose: print class_definition # Execute the template string in a temporary namespace and support # tracing utilities by setting a value for frame.f_globals['__name__'] namespace = dict(_itemgetter=_itemgetter, __name__='namedtuple_%s' % typename, OrderedDict=OrderedDict, _property=property, _tuple=tuple) try: exec class_definition in namespace except SyntaxError as e: raise SyntaxError(e.message + ':\n' + class_definition) result = namespace[typename] # For pickling to work, the __module__ variable needs to be set to the frame # where the named tuple is created. Bypass this step in environments where # sys._getframe is not defined (Jython for example) or sys._getframe is not # defined for arguments greater than 0 (IronPython). try: result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__') except (AttributeError, ValueError): pass return result ######################################################################## ### Counter ######################################################################## class Counter(dict): '''Dict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] >>> sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] >>> ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' >>> sum(c.values()) # total of all counts 15 >>> c['a'] # count of letter 'a' 5 >>> for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count >>> c['a'] # now there are seven 'a' 7 >>> del c['b'] # remove all 'b' >>> c['b'] # now there are zero 'b' 0 >>> d = Counter('simsalabim') # make another counter >>> c.update(d) # add in the second counter >>> c['a'] # now there are nine 'a' 9 >>> c.clear() # empty the counter >>> c Counter() Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared: >>> c = Counter('aaabbc') >>> c['b'] -= 2 # reduce the count of 'b' by two >>> c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)] ''' # References: # http://en.wikipedia.org/wiki/Multiset # http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html # http://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm # http://code.activestate.com/recipes/259174/ # Knuth, TAOCP Vol. II section 4.6.3 def __init__(*args, **kwds): '''Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter(a=4, b=2) # a new counter from keyword args ''' if not args: raise TypeError("descriptor '__init__' of 'Counter' object " "needs an argument") self = args[0] args = args[1:] if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) super(Counter, self).__init__() self.update(*args, **kwds) def __missing__(self, key): 'The count of elements not in the Counter is zero.' # Needed so that self[missing_item] does not raise KeyError return 0 def most_common(self, n=None): '''List the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter('abcdeabcdabcaba').most_common(3) [('a', 5), ('b', 4), ('c', 3)] ''' # Emulate Bag.sortedByCount from Smalltalk if n is None: return sorted(self.iteritems(), key=_itemgetter(1), reverse=True) return _heapq.nlargest(n, self.iteritems(), key=_itemgetter(1)) def elements(self): '''Iterator over elements repeating each as many times as its count. >>> c = Counter('ABCABC') >>> sorted(c.elements()) ['A', 'A', 'B', 'B', 'C', 'C'] # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> product = 1 >>> for factor in prime_factors.elements(): # loop over factors ... product *= factor # and multiply them >>> product 1836 Note, if an element's count has been set to zero or is a negative number, elements() will ignore it. ''' # Emulate Bag.do from Smalltalk and Multiset.begin from C++. return _chain.from_iterable(_starmap(_repeat, self.iteritems())) # Override dict methods where necessary @classmethod def fromkeys(cls, iterable, v=None): # There is no equivalent method for counters because setting v=1 # means that no element can have a count greater than one. raise NotImplementedError( 'Counter.fromkeys() is undefined. Use Counter(iterable) instead.') def update(*args, **kwds): '''Like dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.update('witch') # add elements from another iterable >>> d = Counter('watch') >>> c.update(d) # add elements from another counter >>> c['h'] # four 'h' in which, witch, and watch 4 ''' # The regular dict.update() operation makes no sense here because the # replace behavior results in the some of original untouched counts # being mixed-in with all of the other counts for a mismash that # doesn't have a straight-forward interpretation in most counting # contexts. Instead, we implement straight-addition. Both the inputs # and outputs are allowed to contain zero and negative counts. if not args: raise TypeError("descriptor 'update' of 'Counter' object " "needs an argument") self = args[0] args = args[1:] if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) iterable = args[0] if args else None if iterable is not None: if isinstance(iterable, Mapping): if self: self_get = self.get for elem, count in iterable.iteritems(): self[elem] = self_get(elem, 0) + count else: super(Counter, self).update(iterable) # fast path when counter is empty else: self_get = self.get for elem in iterable: self[elem] = self_get(elem, 0) + 1 if kwds: self.update(kwds) def subtract(*args, **kwds): '''Like dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.subtract('witch') # subtract elements from another iterable >>> c.subtract(Counter('watch')) # subtract elements from another counter >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch 0 >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch -1 ''' if not args: raise TypeError("descriptor 'subtract' of 'Counter' object " "needs an argument") self = args[0] args = args[1:] if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) iterable = args[0] if args else None if iterable is not None: self_get = self.get if isinstance(iterable, Mapping): for elem, count in iterable.items(): self[elem] = self_get(elem, 0) - count else: for elem in iterable: self[elem] = self_get(elem, 0) - 1 if kwds: self.subtract(kwds) def copy(self): 'Return a shallow copy.' return self.__class__(self) def __reduce__(self): return self.__class__, (dict(self),) def __delitem__(self, elem): 'Like dict.__delitem__() but does not raise KeyError for missing values.' if elem in self: super(Counter, self).__delitem__(elem) def __repr__(self): if not self: return '%s()' % self.__class__.__name__ items = ', '.join(map('%r: %r'.__mod__, self.most_common())) return '%s({%s})' % (self.__class__.__name__, items) # Multiset-style mathematical operations discussed in: # Knuth TAOCP Volume II section 4.6.3 exercise 19 # and at http://en.wikipedia.org/wiki/Multiset # # Outputs guaranteed to only include positive counts. # # To strip negative and zero counts, add-in an empty counter: # c += Counter() def __add__(self, other): '''Add counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): newcount = count + other[elem] if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count > 0: result[elem] = count return result def __sub__(self, other): ''' Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): newcount = count - other[elem] if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count < 0: result[elem] = 0 - count return result def __or__(self, other): '''Union is the maximum of value in either of the input counters. >>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): other_count = other[elem] newcount = other_count if count < other_count else count if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count > 0: result[elem] = count return result def __and__(self, other): ''' Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): other_count = other[elem] newcount = count if count < other_count else other_count if newcount > 0: result[elem] = newcount return result if __name__ == '__main__': # verify that instances can be pickled from cPickle import loads, dumps Point = namedtuple('Point', 'x, y', True) p = Point(x=10, y=20) assert p == loads(dumps(p)) # test and demonstrate ability to override methods class Point(namedtuple('Point', 'x y')): __slots__ = () @property def hypot(self): return (self.x ** 2 + self.y ** 2) ** 0.5 def __str__(self): return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) for p in Point(3, 4), Point(14, 5/7.): print p class Point(namedtuple('Point', 'x y')): 'Point class with optimized _make() and _replace() without error-checking' __slots__ = () _make = classmethod(tuple.__new__) def _replace(self, _map=map, **kwds): return self._make(_map(kwds.get, ('x', 'y'), self)) print Point(11, 22)._replace(x=100) Point3D = namedtuple('Point3D', Point._fields + ('z',)) print Point3D.__doc__ import doctest TestResults = namedtuple('TestResults', 'failed attempted') print TestResults(*doctest.testmod())
Save
cmd:
run