[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-682216-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-682216-en":130,"doc-similar-682216":154},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","python-code-style-guide-introduction-format-and-use-of-white-space","Python Code Style Guide - Introduction - Format and use of White Space","","Python Code Style Guide outlines how programming style choices improve code correctness, readability, and maintainability. It discusses why stylistic conventions matter for communication, drawing parallels to written language and established editorial principles. The guide then explains formatting fundamentals: using whitespace structure to reflect semantic organization, employing indentation to express hierarchy in Python, deciding on tabs versus spaces with PEP 8 guidance, and applying vertical whitespace rules to separate logical blocks and steps.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/python-code-style-guide-introduction-format-and-use-of-white-space/682216/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/python-code-style-guide-introduction-format-and-use-of-white-space/682216.png","ImageObject",300,407,{"name":42,"@type":43},"Đào","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-10","2026-11-06",true,{"@type":52,"interactionType":53,"userInteractionCount":30},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"Why does the guide emphasize programming style beyond syntax?","Question",{"text":62,"@type":63},"It argues that stylistic decisions affect communication and readability, just as in written language. Style also reduces the likelihood of common errors and creates conventions understood by experienced readers.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"How does Python represent code hierarchy if it has no curly braces?",{"text":67,"@type":63},"Python expresses hierarchical structure entirely through indentation. Correct indentation is therefore not only stylistic but also essential for correct interpretation.",{"name":69,"@type":60,"acceptedAnswer":70},"What does PEP 8 recommend for indentation and vertical spacing?",{"text":71,"@type":63},"PEP 8 recommends 4 spaces per indentation level instead of tabs. It also recommends a single blank line between distinct code blocks within a method and a single blank line between methods or declarations within a class, with two blank lines for global methods or declarations outside a class.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},682216,1793963005,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":30,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":79,"read_time":144,"preview_page_count":26,"preview_urls":145},1374402968488,"https://ap-avatar.wpscdn.com/davatar_29158cc5080c5b710cf443261637dec0","Python Code Style Guide  \n1. Introduction  \nMost of this course focuses on the elements of a programming language and how to employ them to write correct code. But, like human languages, progrmming languages also leave considerable room for style (how we choose to express a particular implementation) .  \nOne might reasonably assume that stylistic decisions are entirely matters of personal choice.  \nIn 1959 Strunk and White’s “The Elements of Style” asserted that the primary purpose of written language was communication, and that stylistic elements can be evaluated based on the extent to which they facilitate understanding; Remove what is superfluous, and ensure that each word and sentence communicates its meaning clearly.  \nSimilar principles apply to thoughts expressed in a programming language. Different programming communities may observe different stylistic conventions, but most communities do have guidelines to improve the readability of their code. Some of these rules are to reduce the likeihood of common errors. Others merely establish common ideoms whose uses will be immediately understood by experienced readers.  \nFor these reasons, it is valuable for you to complement your understanding of syntax and sematics with an appreciation for the elements of programming style:  \n• what are the key stylistic elements, and how do they effect code readability?  \n• examples of common usage conventions, and what advantages do they confer?  \n2. Format and use of White Space  \nThe simplest stylistic elements of a written program involve the ways in which the words/tokens are arranged into lines. Newlines, tabs, and spaces are collectively referred to as “white space”. We see white-space conventions in written prose:  \n• the flow of sentences within a paragraph shows them to be connected thoughts.  \n• the blank lines between paragraphs show them to be distinct thoughts.  \n• the sub-indentation of a bulleted list shows an enumeration of distinct sub-elements.  \n• a new chapter or sub-section may start on a new page, to clearly indicate the start of a new subject.  \nThese are examples of how the arrangement of the characters on a page can suggest (or reinforce) the semantic structure of the presentation, making it easier for the reader to absorb the presented material.  \nWhite space can be employed very similarly in most programming languages.  \n2.1 Indentation  \nIndentation is commonly used to indicate subordination:  \n• the methods within a class are indented to the right of the class definition.  \n• the code within a method is indented to the right of the method definition.  \n• in an if statement, the if and else clauses are indented to the right of the if and else keywords.  \n• the body of a loop is indented to the right of the while/for statement that controls the loop.  \nIn most languages this subordination is defined by matching curly braces (or parentheses, or square or angle brackets) . . . and indentation is a purely stylistic element to make this structure more obvious. Python does not use braces/brackets; The hierarchical structure of the code is expressed entirely through indentation. Thus, correct indentation in Python is not merely a matter of style.  \nShould we achieve our indentation with tabs or spaces? Arguments can be made for either convention, but there seems to be a general consensus that mixing tabs and spaces is a bad idea (because the per tab indentation may be different on different systems) . The Python PEP-8 standard recommends use of 4-spaces per level of indentation (rather than tabs) . This enables more levels of nesting within a limited line length.  \n2.2 Vertical White Space  \nJust as inter-paragraph spacing is used to separate distinct thoughts, programming styles encourage the use of vertical white space to separate logically distinct code elements: -classes or methods within a module-variable declarations/initializations from code-distinct processing steps within a method  \nThe Python PEP-8 standard","cbCainsx8mkxlt2W","https://ap.wps.com/l/cbCainsx8mkxlt2W","pdf",214766,15,"English","# Introduction\n# Format and use of White Space\n## Indentation\n## Vertical White Space\n## Line Length and continuations","[{\"question\":\"Why does the guide emphasize programming style beyond syntax?\",\"answer\":\"It argues that stylistic decisions affect communication and readability, just as in written language. Style also reduces the likelihood of common errors and creates conventions understood by experienced readers.\"},{\"question\":\"How does Python represent code hierarchy if it has no curly braces?\",\"answer\":\"Python expresses hierarchical structure entirely through indentation. Correct indentation is therefore not only stylistic but also essential for correct interpretation.\"},{\"question\":\"What does PEP 8 recommend for indentation and vertical spacing?\",\"answer\":\"PEP 8 recommends 4 spaces per indentation level instead of tabs. It also recommends a single blank line between distinct code blocks within a method and a single blank line between methods or declarations within a class, with two blank lines for global methods or declarations outside a class.\"}]","Python Code Style Guide - Introduction - Format and use of White Space | PDF",38,[146,150],{"page_no":22,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-06/b5e2ca6d6de26d0e8ff6286decb3e7c9.webp",983,1272,{"page_no":26,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-06/982d1d704417960f6b3203725bae2377.webp",982,1270,{"list":155,"token":11},[156,162,168,174,180,186,192,198,204,210],{"doc_id":157,"doc_title":158,"file_type":137,"home_preview_img_url":159,"slug":160,"view_count":101,"category_name":29,"create_tm":161},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=1796110379&Signature=ykMHLYK4q5WNtE%2FTD0Cny8cUzV0%3D","python-style-rules-docstring-conventions-coding-style",1793963012,{"doc_id":163,"doc_title":164,"file_type":137,"home_preview_img_url":165,"slug":166,"view_count":105,"category_name":29,"create_tm":167},692314,"CS 116 Course Specific Style Guide - Document","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230003205286/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110379&Signature=2pZY4sO0LsOjIcY46Exo3cgZ1WY%3D","cs-116-course-specific-style-guide-document",1794193120,{"doc_id":169,"doc_title":170,"file_type":137,"home_preview_img_url":171,"slug":172,"view_count":96,"category_name":29,"create_tm":173},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=1796110379&Signature=6fkm9skd6LhvIoKq6CWSg4XfNq8%3D","python-pep8-the-style-guide-for-python-code",1793963024,{"doc_id":175,"doc_title":176,"file_type":137,"home_preview_img_url":177,"slug":178,"view_count":96,"category_name":29,"create_tm":179},692315,"Good Coding Practices - Python Code Best Practices","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230002739157/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110379&Signature=fju%2Fh%2B7m%2Bu0kI0d0pLC%2BqpCkHBU%3D","good-coding-practices-python-code-best-practices",1794193122,{"doc_id":181,"doc_title":182,"file_type":137,"home_preview_img_url":183,"slug":184,"view_count":101,"category_name":29,"create_tm":185},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=1796110379&Signature=Rah1AX5QypIbwA3ha1g2Llg1Gpw%3D","python-pep8-style-guide-cheat-sheet-naming-conventions-maximum-line-length-and-line-breaking-indentation-comments-code-layout",1793963021,{"doc_id":187,"doc_title":188,"file_type":137,"home_preview_img_url":189,"slug":190,"view_count":101,"category_name":29,"create_tm":191},682220,"Style Guide for CS 231 and CS 234 - Python Style Requirements","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229998448640/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110379&Signature=rwx4V0aHoLV9AFyfIrDixYZ%2BNDs%3D","style-guide-for-cs-231-and-cs-234-python-style-requirements",1793963013,{"doc_id":193,"doc_title":194,"file_type":137,"home_preview_img_url":195,"slug":196,"view_count":33,"category_name":29,"create_tm":197},700988,"Java Code Conventions - 1997-09-12 - Copyright and code style guidelines","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230012045653/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110379&Signature=o5wHhrfAdXDD2niDGSaHh7qDPB0%3D","java-code-conventions-1997-09-12-copyright-and-code-style-guidelines",1794522632,{"doc_id":199,"doc_title":200,"file_type":137,"home_preview_img_url":201,"slug":202,"view_count":33,"category_name":29,"create_tm":203},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=1796110379&Signature=TibGL4dlkWjilrZr%2FI1%2BiMQebzs%3D","a-python-style-guide-draft",1793963006,{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":101,"category_name":29,"create_tm":209},672869,"Google HTML/CSS Style Guide - Formatting and style rules","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229989673248/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110379&Signature=CPP3Wo9wwEydjOcnNU8xLRDiKXk%3D","google-htmlcss-style-guide-formatting-and-style-rules",1793611799,{"doc_id":211,"doc_title":212,"file_type":137,"home_preview_img_url":213,"slug":214,"view_count":139,"category_name":29,"create_tm":215},391232,"Python Interview Questions - List vs Tuples - Key Features","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917654344/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110379&Signature=dzD4OKnPk8xoyUvrML5h%2BVIZ54U%3D","python-interview-questions-list-vs-tuples-key-features",1790350253]