# "PEP 8(E731): do not assign a lambda expression, use a def"

在解决[python多层嵌套字典KeyError](https://github.com/huataihuang/cloud-atlas-draft/tree/6f3204fffc11cf006abd394631e2598d98b415c3/develop/python/startup/nested_dictionary_key_error/README.md)时候，我使用了 `lambda`的方法来构建一个复杂的嵌套字典，能够正常运行，但是在使用Python开发IDC（使用sublime+SimplePythonIDC）发现在以下这段代码第一行

```
mydict = lambda: defaultdict(mydict)
vm_perf = mydict()
```

有如下提示信息：

```
[W] PEP 8(E731): do not assign a lambda expression, use a def, 3 matches
```

## 参考


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/develop/python/startup/assign_lambda_expression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
