Intermezzo:Coding style

When writing long codes , its important that , as a programmer , you write your code in the best possible structure that is readable to others. Most languages can be written in different styles, and one may be better than the other. Choosing an appropriate coding style is important so that reading your code is not itching to the eyes.
PEP8 has emerged as the style guide that most codes adhere to. The most important points that needs to be followed are:
1)Use 4-space indentation and no tabs .

2)Use blank lines to separate functions and classes and large blocks of code within functions

3)Use comments when possible

4)Use docstrings in classes and functions.

5)Use spaces around operators and commas e.g —– ‘c = a + b’

6)Naming your classes and functions consistently. Always use ‘self’ as the name for the first argument a method in the class.

7)Wrap lines so that they don’t exceed 79 characters.

Try using all of the above listed particulars and make you code eye-pleasing and obviously easy to understand.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s