[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-692315-105":59,"doc-detail-692315-en":130,"doc-similar-692315":157},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","good-coding-practices-python-code-best-practices","Good Coding Practices - Python Code Best Practices","","Good Coding Practices by Daniel Perrefort outlines what qualifies as a best practice and shows how effective procedures improve maintainability, clarity, and consistency in software development. It presents a roadmap covering PEPs and styling, documentation writing, and project organization. The guide emphasizes key Python references such as PEP 8 (style), PEP 20 (readability principles), and PEP 257 (docstrings), with bonus PEPs including type hints and string interpolation. It then provides practical coding and naming conventions, including layout rules and recommendations for Python idioms like singleton comparisons.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/good-coding-practices-python-code-best-practices/692315/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/good-coding-practices-python-code-best-practices/692315.png","ImageObject",300,407,{"name":92,"@type":93},"Emma Wilson","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-24","2026-11-09",true,{"@type":102,"interactionType":103,"userInteractionCount":24},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What defines a best practice in this guide?","Question",{"text":112,"@type":113},"Best practices are procedures accepted as the most effective, either by consensus or prescription. They can range from stylistic choices to in-depth design methodologies.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"Which PEPs are highlighted as important fundamentals?",{"text":117,"@type":113},"The document highlights PEP 8 as the Style Guide for Python Code, PEP 20 as The Zen of Python, and PEP 257 for Docstring Conventions.",{"name":119,"@type":110,"acceptedAnswer":120},"What are the key code layout and formatting recommendations?",{"text":121,"@type":113},"It recommends using 4 spaces per indentation level (not tabs), placing two blank lines before functions and classes, and limiting line lengths to 79 characters for code and 72 for long blocks of text, with the option to increase up to 99 characters.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},692315,1794193122,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":24,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":129,"read_time":144,"preview_page_count":81,"preview_urls":145},3848291630094,"https://eur-avatar.wpscdn.com/davatar_085a072bc5b1113ac321206ff7593b45","Good Coding Practices  \nDaniel Perrefort – University of Pittsburgh  \nWhat is a Best Practice?  \n􀁘 Best practices are any procedure that is accepted as being the most effective either by consensus or by prescription.  \n􀁘 Practices can range from stylistic to in-depth design methodologies.  \n\"A universal convention supplies all of maintainability, clarity, consistency, and a  \nfoundation for good programming habits too. \"  \n—Tim Peters on comp.lang.python, 2001-06-16  \nA Roadmap  \nPEP’s and good styling  \nWriting good documentation  \nHow to organize your project  \nPython Enhancement Protocol (PEP)  \n“A PEP is a design document providing information to the Python community, or describing a new feature for Python or its processes or environment.”(PEP 1)  \n\n| Important Fundamentals | PEP 8: Style Guide for Python Code |\n| --- | --- |\n|  | PEP 20: The Zen of Python |\n|  | PEP 257: Docstring Conventions |\n\nBonus PEPs  \nPEP 484: Type  \nHints  \nPEP 498: Literal String Interpolation  \nPEP 572: Assignment Expressions  \nPEP 20: The Zen of Python  \n>>> import this  \nBeautiful is better than ugly.  \nExplicit is better than implicit.  \nSimple is better than complex.  \nComplex is better than complicated.  \nFlat is better than nested.  \nSparse is better than dense.  \nReadability counts.  \nSpecial cases aren't special enough to break the rules.  \nAlthough practicality beats purity.  \nErrors should never pass silently.  \nUnless explicitly silenced.  \nIn the face of ambiguity, refuse the temptation to guess.  \nThere should be one--and preferably only one--obvious way to do it.  \nAlthough that way may not be obvious at first unless you're Dutch. Now is better than never.  \nAlthough never is often better than *right* now.  \nIf the implementation is hard to explain, it's a bad idea.  \nIf the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea-- let's do more of those!  \nPEP 8: Style Guide for Python Code  \nCode is read much more often than it is written.  \nEasy to read means easier to develop.  \nWell written code conveys professionalism.  \nCode is a deliverable part of your project!  \nPEP8: Code Layout  \nYour probably already familiar with…  \n􀁘 Using 4 spaces per indentation level (not tabs!)  \n􀁘 Putting two blank lines before functions and classes  \n􀁘 Limiting line lengths to:  \n􀁘 79 characters for code  \n􀁘 72 characters for long blocks of text  \n􀁘 It is okay to increase the line length limit up to 99 characters  \nPEP8: Code Layout  \n\\# !/usr/bin/env python3.7  \n\\# - * -coding: UTF-8- * -  \n\"\"\"This is a description of the module.\"\"\"  \nimport json  \nimport os  \nfrom astropy.table import Table, vstack from my_code import utils  \n  version  = 0.1  \ndef my_function():  \n...  \nPEP 8: Naming Conventions  \n\n| TYPE | NAM ING CONVENTION | EXAMPLES |\n| --- | --- | --- |\n| Function | Use lowercase words separated by underscores. | function, my_function |\n| Variable | Use lowercase letters or word, or words separated with underscores. (I.e. , snake_case) | x, var, my_variable |\n| Class | Start each word with a capital letter. Do not separate words with underscores. (I.e. , CamalCase) | Model, MyClass |\n| Method | Use lowercase words separated with underscores. | class_method, method |\n| Constant | Use an uppercase single letter, word, or words separated by underscores. | CONSTANT, MY_CONSTANT |\n| Module | Use short lowercase words separated with underscores. | [module.py](module.py), [my_module.py](my_module.py) |\n| Package | Use short lowercase words without underscores. | package, mypackage |\n\nPEP8: General Recommendations  \n􀁘 Use `is` when comparing singletons  \n􀁘 Use `is not` instead of `not ... is`  \n\\# Wrong  \nif foo == None: do_something()  \n\\# Also wrong  \nif not foo is None: do_something()  \n\\# Correct  \nif foo is not None: do_something()","cbCaia0zfYFvsVDF","https://ap.wps.com/l/cbCaia0zfYFvsVDF","pdf",594906,29,"English","# What is a Best Practice?\n# A Roadmap\n## PEP’s and good styling\n## Writing good documentation\n## How to organize your project\n# Python Enhancement Protocol (PEP)\n## Important Fundamentals\n## Bonus PEPs\n# The Zen of Python\n# PEP 8 Code Layout\n# PEP 8 Naming Conventions\n# PEP8 General Recommendations","[{\"question\":\"What defines a best practice in this guide?\",\"answer\":\"Best practices are procedures accepted as the most effective, either by consensus or prescription. They can range from stylistic choices to in-depth design methodologies.\"},{\"question\":\"Which PEPs are highlighted as important fundamentals?\",\"answer\":\"The document highlights PEP 8 as the Style Guide for Python Code, PEP 20 as The Zen of Python, and PEP 257 for Docstring Conventions.\"},{\"question\":\"What are the key code layout and formatting recommendations?\",\"answer\":\"It recommends using 4 spaces per indentation level (not tabs), placing two blank lines before functions and classes, and limiting line lengths to 79 characters for code and 72 for long blocks of text, with the option to increase up to 99 characters.\"}]","Good Coding Practices - Python Code Best Practices | PDF",73,[146,150,153],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/6e456438fbfd17989898f04ac5008049.webp",983,552,{"page_no":14,"url":151,"width":152,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/0e6604f5b29225e2da0f09be39f0bd2c.webp",982,{"page_no":81,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/403b02df27e4a5f88690870cf64847b6.webp",981,551,{"list":158,"token":66},[159,165,171,177,183,189,195,201,207,213],{"doc_id":160,"doc_title":161,"file_type":137,"home_preview_img_url":162,"slug":163,"view_count":29,"category_name":30,"create_tm":164},682219,"Python Style Rules - Docstring Conventions - Coding Style","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229998448620/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=%2Bw2b91VDB157DKqrJcDk5OCxjVY%3D","python-style-rules-docstring-conventions-coding-style",1793963012,{"doc_id":166,"doc_title":167,"file_type":137,"home_preview_img_url":168,"slug":169,"view_count":19,"category_name":30,"create_tm":170},692325,"Python Coding Standards - Version A - Released","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230003217830/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=Ld6CrPDBYvNVE2pcqUPhAC5ia8g%3D","python-coding-standards-version-a-released",1794193583,{"doc_id":172,"doc_title":173,"file_type":137,"home_preview_img_url":174,"slug":175,"view_count":81,"category_name":30,"create_tm":176},682216,"Python Code Style Guide - Introduction - Format and use of White Space","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999427657/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=RtmRne64D4V4WQDBkN9WxYqa1kg%3D","python-code-style-guide-introduction-format-and-use-of-white-space",1793963005,{"doc_id":178,"doc_title":179,"file_type":137,"home_preview_img_url":180,"slug":181,"view_count":29,"category_name":30,"create_tm":182},682223,"Python PEP8 style guide - Cheat Sheet - Naming conventions - Maximum Line Length and Line Breaking - Indentation - Comments - Code Layout","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999427735/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=fUTp1vWMj2xF%2FDpZCckPhjjDHgg%3D","python-pep8-style-guide-cheat-sheet-naming-conventions-maximum-line-length-and-line-breaking-indentation-comments-code-layout",1793963021,{"doc_id":184,"doc_title":185,"file_type":137,"home_preview_img_url":186,"slug":187,"view_count":24,"category_name":30,"create_tm":188},682224,"Python PEP8 - The Style Guide for Python Code","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999427682/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=eNdpda5LBdROyDtjPWvL22MJIlU%3D","python-pep8-the-style-guide-for-python-code",1793963024,{"doc_id":190,"doc_title":191,"file_type":137,"home_preview_img_url":192,"slug":193,"view_count":19,"category_name":30,"create_tm":194},682217,"A Python Style Guide - Draft","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229998448576/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=AchyGnudPOSoWgVwFuUaOtWGuMY%3D","a-python-style-guide-draft",1793963006,{"doc_id":196,"doc_title":197,"file_type":137,"home_preview_img_url":198,"slug":199,"view_count":52,"category_name":30,"create_tm":200},692230,"Python Handbook - Updated October 14, 2026","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230003011060/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=qu0ViJZb44oXG0wVcyCMRhK97Z0%3D","python-handbook-updated-october-14-2026",1794186375,{"doc_id":202,"doc_title":203,"file_type":137,"home_preview_img_url":204,"slug":205,"view_count":34,"category_name":30,"create_tm":206},670917,"Python 3 Cheat Sheet - concise reference","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988704071/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=JSEZF0pTXr5DxbNIl1H1OIbBEI4%3D","python-3-cheat-sheet-concise-reference",1793572698,{"doc_id":208,"doc_title":209,"file_type":137,"home_preview_img_url":210,"slug":211,"view_count":52,"category_name":30,"create_tm":212},673607,"Python with Hermione - Paper OS-323 - Unleash your Inner Coding Witch and Dragon","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229991569968/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=8L8H6z1zvs5t7SnENzFn%2BR3Strs%3D","python-with-hermione-paper-os-323-unleash-your-inner-coding-witch-and-dragon",1793685716,{"doc_id":214,"doc_title":215,"file_type":137,"home_preview_img_url":216,"slug":217,"view_count":24,"category_name":30,"create_tm":218},682215,"Integers and floats - Python programming style guidance","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229998448523/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=%2BjiBtPt4sPdIlY5kF9Aw%2FdpKcYg%3D","integers-and-floats-python-programming-style-guidance",1793963004]