Python – Readability

Python is NOT a “free-format” language.
It was designed to be a highly readable language.
It uses whitespace to delimit program blocks, following the off-side rule.

From these points, I don’t think that the off-side rule is good enough to make the program highly readable. Because I have come across Python scripts that are hardly readable.

Example 1:

if row==0:
  empLastName=  'Red'
  empSalary =  5000

This could be written in a better way.

if row == 0:
    empFirstName   = 'Green'
    empLastName    = 'Red'
    empAge         = 35
    empDateOfBirth = '14/04/2012'
    empSalary      = 5000
    process_emp(empFirstName, empLastName, empAge,
                empDateOfBirth, empSalary)

Python tries to be readable by enforcing off-side rule.
But still, it has to recommend PEP 8 and PEP 20 to make the programs really highly readable.

So, its not just Python; even C++ or Perl can be highly readable by adhering to the style guides and with a little common sense. Programming can be an art when accompanied by Aesthetics

Happy Programming!


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