Skip to content

Commit 4b5aa6b

Browse files
committed
added popd
svn path=/trunk/matplotlib/; revision=716
1 parent 99412fd commit 4b5aa6b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/matplotlib/cbook.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,19 @@ def allpairs(x):
411411
assert( not allequal(('a', 'b')))
412412

413413

414+
# python 2.2 dicts don't have pop
414415
def popd(d, *args):
416+
"""
417+
Should behave like python2.3 pop method; d is a dict
418+
419+
# returns value for key and deletes item; raises a KeyError if key
420+
# is not in dict
421+
val = popd(d, key)
422+
423+
# returns value for key if key exists, else default. Delete key,
424+
# val item if it exists. Will not raise a KeyError
425+
val = popd(d, key, default)
426+
"""
415427
if len(args)==1:
416428
key = args[0]
417429
val = d[key]

0 commit comments

Comments
 (0)