You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
18 lines
496 B
Python
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")
|