diff options
Diffstat (limited to 'coverage/backward.py')
-rw-r--r-- | coverage/backward.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 62ca495..5aff640 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -59,18 +59,29 @@ except ImportError: # in Python versions earlier than 3.3. from pipes import quote as shlex_quote -# A function to iterate listlessly over a dict's items. +# A function to iterate listlessly over a dict's items, and one to get the +# items as a list. try: {}.iteritems except AttributeError: + # Python 3 def iitems(d): """Produce the items from dict `d`.""" return d.items() + + def litems(d): + """Return a list of items from dict `d`.""" + return list(d.items()) else: + # Python 2 def iitems(d): """Produce the items from dict `d`.""" return d.iteritems() + def litems(d): + """Return a list of items from dict `d`.""" + return d.items() + # Getting the `next` function from an iterator is different in 2 and 3. try: iter([]).next |