Writingley
    Facebook Twitter Instagram
    Saturday, April 1
    • Privacy Policy
    • Disclaimer
    • Contact Us
    • About Us
    Facebook Twitter Instagram LinkedIn VKontakte
    Writingley
    • Home
    • Business

      Top 5 Futures Market Trends

      March 28, 2023

      Who Is Arthur Britto? Career, Personal Life, Net Worth, And All Other Info

      March 26, 2023

      Get the Best Silver Coins Price in Canada

      March 21, 2023

      How to Turn on Airpods When Case is Dead

      March 13, 2023

      Advice on How to Choose The Ideal Plastic Bottle for Your Product

      March 2, 2023
    • Technology

      Best Practices for Qlik Sense Development: Ensuring Success for Your BI Project.

      April 1, 2023

      What Is Call Centre Monitoring and Why Is It Important?

      March 17, 2023

      Features of VoIP Phone System

      March 3, 2023

      Top 5 Photo Editing Apps to Enhance Your Smartphone Photography

      March 2, 2023

      Eco-Friendly Mobile Repairs: How Mobile Repair Shops are Going Green?

      February 24, 2023
    • Home Improvement
    • Lifestyle
      • Fashion
      • Travel
      • Health
      • Art
      • Recipe
      • Pets
      • Fitness
    • Gaming
    • More
      • Digital Marketing
      • Automobile
      • Real Estate
      • Education
      • World
      • Law
      • Finance
      • Sports
      • Entertainment
    • Contact
    Writingley
    You are at:Home » 8 Ridiculous Rules about PYTHON’s Indentation
    Tech

    8 Ridiculous Rules about PYTHON’s Indentation

    hassanshabeer457By hassanshabeer457March 22, 2022Updated:August 4, 2022No Comments5 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Ridiculous
    Programming Script Text Coding Word
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Last Updated on August 4, 2022 by rabiamuzaffar

    People have been pondering about Python’s use of whitespaces for a long time, and the debate is still going on. Many people believe that there isn’t any definitive way to do it well, so they leave it up to each individual programmer. In this article, I’m going to share my thoughts on the matter, list all existing options and try to point out their pros and cons.

    I don’t claim to be an expert in Python indentation at all (there aren’t many experts around), but I’ve learned a lot throughout the years while trying different styles and discussing them with other programmers. My main objective is to open your eyes towards other available choices you might want to take into consideration before making your final decision regarding this matter.

    Of course, the choice is entirely up to you, but I firmly believe it’s worth spending some time on this matter in order to avoid making a terrible decision that will be hard to revert later on.

    Here are 8 Ridiculous Rules about PYTHON’s Indentation:

    1. Follow PEP 8 guidelines

    Some of you might be surprised to see this one on top of the list, but there are many people out there who obey this rule religiously. If you don’t know what PEP 8 is, here’s a short explanation: it’s a coding standard for Python created by Guido himself, so you’d better follow it!

    2. Tab or no tab? That is the question…

    Most people believe that using tabs for indentation is bad because they don’t align properly when code is being viewed at different resolutions. Instead, spaces should be used according to popular belief. What most people don’t know though, is that there isn’t any hard rule regarding this matter (except for whitespace at the end of).

    3. Use a single space character for indentation

    Even though the original PEP 8 draft recommended a tab size of 4 spaces, they decided to go with a single space instead. This is because the majority of IDEs nowadays are using either 2 or 4 spaces as default tab size, so using a different size would make code harder to read on them. In addition, some people believe that horizontal white space should be minimized in order to make code more compact and readable. You can decide which one you want to use though – it’s still up to you!

    4. Never mix tabs and spaces

    This means that if you’re going to use spaces for indentation then everything should consistently use that number – no mixing whatsoever! I’m not even going to start about this one because it’s ridiculous. Just don’t.

    5. Put opening braces on the same line as the function declaration/class definition/etc

    Some people put their opening braces on a separate line above their functions

    Which style you choose is completely up to you, but I personally prefer the first one because I find that other way messier and harder to read. However, once again – there isn’t any hard rule regarding this, so you should choose the style that best suits your needs.

    6. Put a new line between functions

    This is a very popular way of writing Python code and it’s being used by many programmers around the globe. It’s also the only style where rules 5 and 6 apply – i.e., there should always be a new line between functions! This rule may seem silly but there are still people out there following it religiously. In my opinion, if you’re going to break any of these rules then at least try not to go against this one 🙂

    7. Always pass an empty list as the last argument in a function call

    In Python, when calling multiple-argument functions, you can specify default values for some arguments, which are used if the caller omits values for them. One of these arguments must be named “args”, and it should always be the last one in order to make this syntax valid:

    That’s why some people put an empty list as the last argument for functions with multiple ones, even though that works too. There is no need to do that though!

    8. Use one import per line

    Some people like using multiple imports on a single line, separated by semicolons. This can make code more readable depending on your coding style I guess, but there are also other ways of importing modules (e.g., from …import *), which are much better when it comes to maintaining code quality in larger projects because they don’t pollute the global namespace.

    Conclusion:

    There you have it – 8 popular (and not-so-popular) Python coding style conventions that are being followed by many programmers out there. Do I recommend using all of them? No, absolutely not! Some of them are just ridiculous IMO, but if you’re programming in a team then at least try to be consistent about their usage. Now that we’ve got that cleared up let’s proceed with more interesting stuff.

    Read more: Know Family Law of Guardian Certificate in Pakistan

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleWhat is a server room – requirements and recommendations
    Next Article 10 Benefits of Cloud That May Change Your Perspective
    hassanshabeer457

    Related Posts

    Speed Boosting Tips by a Cell Phone Repair Store in Burlington

    March 30, 2023

    6 elements you need to know before building landscaping website

    March 29, 2023

    Advantages of office professional plus 2021 volume license

    March 28, 2023

    Comments are closed.

    Archives
    • April 2023
    • March 2023
    • February 2023
    • January 2023
    • December 2022
    • November 2022
    • October 2022
    • September 2022
    • August 2022
    • July 2022
    • June 2022
    • May 2022
    • April 2022
    • March 2022
    • February 2022
    • January 2022
    • December 2021
    • November 2021
    • October 2021
    • September 2021
    • August 2021
    • July 2021
    • June 2021
    • May 2021
    • April 2021
    • March 2021
    • February 2021
    • January 2021
    • December 2020
    • September 2020
    • July 2020
    • June 2020
    • May 2020
    • April 2020
    • September 2019
    • June 2019
    • May 2019
    • September 2017
    Categories
    • Art
    • Automobile
    • Business
    • Daily Bites
    • Digital Marketing
    • Education
    • Entertainment
    • Fashion
    • Finance
    • Fitness
    • Gaming
    • Health
    • Home Improvement
    • Law
    • Lifestyle
    • Pets
    • Real Estate
    • Recipe
    • Sports
    • Tech
    • Technology
    • Travel
    • Uncategorized
    • What's hot
    • World
    Meta
    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    • Facebook
    • Twitter
    • Instagram
    • Pinterest
    Don't Miss

    Clean Your Way Into Your New Home: The Complete Sewage Cleaning Checklist

    Best Practices for Qlik Sense Development: Ensuring Success for Your BI Project.

    Choosing the Right Garage Door Spring Replacement Service

    Speed Boosting Tips by a Cell Phone Repair Store in Burlington

    E-mail Newsletter
    • Facebook
    • GitHub
    • Instagram
    • Pinterest
    • Twitter
    • YouTube
    Footer menu
    • Privacy Policy
    • Disclaimer
    • Contact Us
    • About Us
    About

    Welcome to writingley.com, it is the right choice for interesting articles, updates, amazing facts on many topics including technology, food, health, recipes, and traveling. We are determined to provide you with the best of our work and we hope you enjoy our articles.

    Facebook Twitter Instagram LinkedIn VKontakte
    Popular Posts

    Clean Your Way Into Your New Home: The Complete Sewage Cleaning Checklist

    April 1, 2023

    Best Practices for Qlik Sense Development: Ensuring Success for Your BI Project.

    April 1, 2023

    Choosing the Right Garage Door Spring Replacement Service

    March 31, 2023
    Copyright © 2023. All rights reserved by Writingley.
    • Home
    • About Us
    • Contact Us
    • Disclaimer
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.