Python 如何从嵌套字典生成单行选择生成器?

Python 如何从嵌套字典生成单行选择生成器?,python,django,Python,Django,我有这样的结构: actions = { 'cat1': { 'visit': { 'id': 1, 'description': 'Desc 1', 'action': 'Act 1', }, }, 'cat2': { 'download': { 'id': 2, 'description': 'Desc

我有这样的结构:

actions = {
    'cat1': {
        'visit': {
            'id': 1,
            'description': 'Desc 1',
            'action': 'Act 1',
        },
    },
    'cat2': {
        'download': {
            'id': 2,
            'description': 'Desc 2',
            'action': 'Act 2',
        },
        'click': {
            'id': 3,
            'description': 'Desc 3',
            'action': 'Act 3',
        },
        ...
    },
    ...
}
以下代码用于为django选择字段生成元组的元组:

CHOICES = []
for a in actions.values():
    for c in a.values():
        CHOICES.append((c['id'], c['description']))
是否可以将上述代码写在一行嵌套的for循环中?

使用map和reduce:

CHOICES = [(c['id'], c['description']) for a in actions.values() for c in a.values()]
 map(lambda x : [x['id'],x['description']],reduce(lambda x,y:x+y.values(),actions.values(),[]))
这是可能的,但不确定是否更清楚。