Python coding standards/best practices [closed]

2019-01-15 23:42发布

In python do you generally use PEP 8 -- Style Guide for Python Code as your coding standards/guidelines? Are there any other formalized standards that you prefer?

8条回答
别忘想泡老子
2楼-- · 2019-01-16 00:18

I follow the PEP8, it is a great piece of coding style.

查看更多
相关推荐>>
3楼-- · 2019-01-16 00:20

To add to bhadra's list of idiomatic guides:

Checkout Anthony Baxter's presentation on Effective Python Programming (from OSON 2005).

An excerpt:

# dict's setdefault method turns this:
if key in dictobj:
    dictobj[key].append(val)
else:
    dictobj[key] = [val]
# into this:
dictobj.setdefault(key,[]).append(val)
查看更多
登录 后发表回答