Files
python-uncompyle6/test/simple_source/bug31/06_listcomp.py
2018-06-24 06:56:30 -04:00

18 lines
496 B
Python

# Python 3.0 comprehensions can produce different code from
# all other Python versions. Thanks, Python!
# Adapted from 3.0 ast.py
# This code is RUNNABLE!
def _format(node):
return [(a, int(b)) for a, b in node.items()]
# Adapted from 3.0 cmd.py
def monthrange(ary, dotext):
return [a[3:] for a in ary if a.startswith(dotext)]
x = {'a': '1', 'b': '2'}
assert [('a', 1), ('b', 2)] == _format(x)
ary = ["Monday", "Twoday", "Monmonth"]
assert ['day', 'month'] == monthrange(ary, "Mon")