Python indentation syntax, pros and cons

Source: Internet
Author: User

Python's syntax is simple--in the form of indentation

There are advantages and disadvantages of indentation:

One of the benefits is forcing you to write formatted code, but it doesn't specify whether the indentation is a few spaces or tab. In accordance with established management, you should always stick to the indentation of 4 spaces.

The second is to force you to write less indented code, and you will tend to split a very long code into several functions , resulting in less code being indented.

The downside of indentation is that the "copy-paste" function fails, which is the most pit-daddy place. When you refactor the code , the pasted past code must re-check that the indentation is correct. In addition, it is difficult for the IDE to format Python code just like formatted Java code.

In addition, in the text editor, you need to set the tab to automatically convert to 4 spaces, ensuring that tab and space are not mixed.

Reference: Liaoche Teacher's Blog

Python indentation syntax, pros and cons

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.