python代码规范[英].docx
上传人:sy****28 上传时间:2024-09-14 格式:DOCX 页数:21 大小:58KB 金币:18 举报 版权申诉
预览加载中,请您耐心等待几秒...

python代码规范[英].docx

python代码规范[英].docx

预览

免费试读已结束,剩余 11 页请下载文档后查看

18 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

HYPERLINK"http://www.python.org/dev/peps/"PEPIndex>PEP8--StyleGuideforPythonCodePEP:8Title:StyleGuideforPythonCodeVersion:89db18c77152Last-Modified:HYPERLINK"http://hg.python.org/peps/file/tip/pep-0008.txt"2013-01-1311:28:10+0100(Sun,13Jan2013)Author:GuidovanRossum<guidoatpython.org>,BarryWarsaw<barryatpython.org>Status:ActiveType:ProcessContent-Type:HYPERLINK"http://www.python.org/dev/peps/pep-0012"text/x-rstCreated:05-Jul-2001Post-History:05-Jul-2001HYPERLINK"http://www.python.org/dev/peps/pep-0008/"\l"id7"IntroductionThisdocumentgivescodingconventionsforthePythoncodecomprisingthestandardlibraryinthemainPythondistribution.PleaseseethecompanioninformationalPEPdescribingstyleguidelinesfortheCcodeintheCimplementationofPythonHYPERLINK"http://www.python.org/dev/peps/pep-0008/"\l"id4"[1].ThisdocumentandHYPERLINK"http://www.python.org/dev/peps/pep-0257"PEP257(DocstringConventions)wereadaptedfromGuido'soriginalPythonStyleGuideessay,withsomeadditionsfromBarry'sstyleguideHYPERLINK"http://www.python.org/dev/peps/pep-0008/"\l"id5"[2].HYPERLINK"http://www.python.org/dev/peps/pep-0008/"\l"id8"AFoolishConsistencyistheHobgoblinofLittleMindsOneofGuido'skeyinsightsisthatcodeisreadmuchmoreoftenthanitiswritten.TheguidelinesprovidedhereareintendedtoimprovethereadabilityofcodeandmakeitconsistentacrossthewidespectrumofPythoncode.AsHYPERLINK"http://www.python.org/dev/peps/pep-0020"PEP20says,"Readabilitycounts".Astyleguideisaboutconsistency.Consistencywiththisstyleguideisimportant.Consistencywithinaprojectismoreimportant.Consistencywithinonemoduleorfunctionismostimportant.Butmostimportantly:knowwhentobeinconsistent--sometimesthestyleguidejustdoesn'tapply.Whenindoubt,useyourbestjudgment.Lookatotherexamplesanddecidewhatlooksbest.Anddon'thesitatetoask!Twogoodreasonstobreakaparticularrule:Whenapplyingtherulewouldmakethecodelessreadable,evenforsomeonewhoisusedtoreadingcodethatfollowstherules.Tobeconsistentwithsurroundingcodethatalsobreaksit(maybeforhist