欢迎来到天天文库
浏览记录
ID:34307125
大小:358.66 KB
页数:23页
时间:2019-03-04
《Google Python Style Guide.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、GooglePythonStyleGuideRevision2.39AmitPatelAntoinePicardEugeneJhongJeremyHyltonMattSmartMikeShieldsEachstylepointhasasummaryforwhichadditionalinformationisavailablebytogglingtheaccompanyingarrowbuttonthatlooksthisway:▽.Youmaytoggleallsummarieswiththebigarrowbutton:▽ToggleallsummariesTa
2、bleofContentsPythonpycheckerImportsPackagesExceptionsLanguageGlobalvariablesRulesNested/Local/InnerClassesandFunctionsListComprehensionsDefaultIteratorsandOperatorsGeneratorsLambdaFunctionsConditionalExpressionsDefaultArgumentValuesPropertiesTrue/FalseevaluationsDeprecatedLanguageFeatu
3、resLexicalScopingFunctionandMethodDecoratorsThreadingPowerFeaturesPythonSemicolonsLinelengthParenthesesIndentationStyleBlankLinesWhitespaceShebangLineCommentsRulesClassesStringsFilesandSocketsTODOCommentsImportsformattingStatementsAccessControlNamingMainImportantNoteDisplayingHiddenDet
4、ailsinthisGuidelink▽Thisstyleguidecontainsmanydetailsthatareinitiallyhiddenfromview.Theyaremarkedbythetriangleicon,whichyouseehereonyourleft.Clickitnow.Youshouldsee"Hooray"appearbelow.Hooray!Nowyouknowyoucanexpandpointstogetmoredetails.Alternatively,there'sa"toggleall"atthetopofthisdoc
5、ument.BackgroundPythonisthemainscriptinglanguageusedatGoogle.Thisstyleguideisalistofdosanddon'tsforPythonprograms.Tohelpyouformatcodecorrectly,we'vecreatedasettingsfileforVim.ForEmacs,thedefaultsettingsshouldbefine.PythonLanguageRulespycheckerlink▽Runpycheckeroveryourcode.Definition:Py
6、CheckerisatoolforfindingbugsinPythonsourcecode.ItfindsproblemsthataretypicallycaughtbyacompilerforlessdynamiclanguageslikeCandC++.Itissimilartolint.BecauseofthedynamicnatureofPython,somewarningsmaybeincorrect;however,spuriouswarningsshouldbefairlyinfrequent.Pros:Catcheseasy-to-misserro
7、rsliketypos,use-vars-before-assignment,etc.Cons:pycheckerisn'tperfect.Totakeadvantageofit,we'llneedtosometimes:a)Writearounditb)Suppressitswarningsc)Improveitord)Ignoreit.Decision:Makesureyourunpycheckeronyourcode.Forinformationonhowtorunpychecker,seethepycheckerhomepageTosuppresswar
此文档下载收益归作者所有