对于更复杂的模块,请查看标准电子邮件包或 Django 源代码。同样,不一定遵循 PEP 8,但已被数千人使用(并受到许多人的喜爱)。
公平地说,明天令人惊叹的 Python 代码与今天良好的工作代码之间存在着平衡。
干杯,
胡安
Have you taken a look at the Python standard library source code? It can give you an idea of the different idiosyncrasies for proper Python style. Not all of them follow PEP 8, but you can learn a lot just by looking. I recommend you look at modules contained in a single file, so that you get the full picture. Specific examples within the source include:
Keep in mind that this does not mean that these modules should be taken as "exemplary Python code" but the point remains: they are good enough as for them to be included in the standard Python distribution.
For more complex modules, take a look at the standard Email package, or the Django source code. Again, not necessarily following PEP 8, but used by thousands (and loved by many).
It's fair to say that there is a balance between amazing Python code tomorrow versus decent working code today.
发布评论
评论(2)
你看过Python标准库源代码吗?它可以让您了解正确的 Python 风格的不同特性。并非所有人都遵循 PEP 8,但您只需看看就可以学到很多东西。我建议您查看单个文件中包含的模块,以便了解完整情况。源中的具体示例包括:
请记住,这并不意味着这些模块应该被视为“示例性 Python 代码”,但要点仍然是:它们足够好,可以包含在标准 Python 发行版中。
对于更复杂的模块,请查看标准电子邮件包或 Django 源代码。同样,不一定遵循 PEP 8,但已被数千人使用(并受到许多人的喜爱)。
公平地说,明天令人惊叹的 Python 代码与今天良好的工作代码之间存在着平衡。
干杯,
胡安
Have you taken a look at the Python standard library source code? It can give you an idea of the different idiosyncrasies for proper Python style. Not all of them follow PEP 8, but you can learn a lot just by looking. I recommend you look at modules contained in a single file, so that you get the full picture. Specific examples within the source include:
Keep in mind that this does not mean that these modules should be taken as "exemplary Python code" but the point remains: they are good enough as for them to be included in the standard Python distribution.
For more complex modules, take a look at the standard Email package, or the Django source code. Again, not necessarily following PEP 8, but used by thousands (and loved by many).
It's fair to say that there is a balance between amazing Python code tomorrow versus decent working code today.
Cheers,
Juan
boto3。很棒的测试套件和包结构。 Celery 也是如此。
boto3. Great test suite and package structure. Same for Celery.