Changes between Version 11 and Version 12 of DevNotes/DevGuide/CodingRules


Ignore:
Timestamp:
May 30, 2016 7:42:09 AM (6 years ago)
Author:
wojciech
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • DevNotes/DevGuide/CodingRules

    v11 v12  
    9494 
    9595    * Imports should be grouped in the following order: 
    96         standard library imports 
    97         related third party imports 
    98         local application/library specific imports 
     96        1. standard library imports 
     97        2. related third party imports 
     98        3. local application/library specific imports 
    9999    * Put a blank line between each group of imports. 
    100100 
    101101Exception Handling 
    102102 
    103     Use if and try/except block to test for errors that could happen in normal program operation 
    104  
    105     If you catch an exception and all you do is calling pass or print, you have not dealt with the error properly 
    106     Exceptions should not be used for flow control, unless there is a very good reason for it 
    107     Error codes from a method should never be returned - use exceptions 
     103    * Use if and try/except block to test for errors that could happen in normal program operation 
     104    * If you catch an exception and all you do is calling pass or print, you have not dealt with the error properly 
     105    * Exceptions should not be used for flow control, unless there is a very good reason for it 
     106    * Error codes from a method should never be returned - use exceptions 
    108107 
    109108Coding Style 
    110109 
    111110When in doubt - follow PEP 8 (https://www.python.org/dev/peps/pep-0008/) 
     111 
    112112Indentation 
    113113 
    114     Use 4 spaces to indent, not tabs. 
    115     Indent 4 spaces per nested level. 
     114    * Use 4 spaces to indent, not tabs. 
     115    * Indent 4 spaces per nested level. 
    116116 
    117117Spaces in Expressions & Statements 
    118118 
    119     Do not put spaces around parentheses, brackets, or curly braces. 
    120     Do not put spaces before commas, colons, or semicolons. 
    121     Put one space around operators. 
    122     However one can use no spaces with operators of higher priority, e.g., y = a*x**2 + b*x + c. 
     119    * Do not put spaces around parentheses, brackets, or curly braces. 
     120    * Do not put spaces before commas, colons, or semicolons. 
     121    * Put one space around operators. 
     122    * However one can use no spaces with operators of higher priority, e.g., y = a*x**2 + b*x + c. 
    123123 
    124124Miscellaneous 
    125125 
    126     Limit lines to a maximum of 79 characters. 
    127     Do not put semicolons at the end of lines. 
    128     Avoid using magic numbers 
     126    * Limit lines to a maximum of 79 characters. 
     127    * Do not put semicolons at the end of lines. 
     128    * Avoid using magic numbers 
    129129    Use: 
    130          max_bins = 7 
    131          if i < max_bins: 
     130    {{{ 
     131    #!div style="font-size: 80%" 
     132    {{{#!python         
     133    max_bins = 7 
     134    if i < max_bins: 
     135    }}} 
     136    }}} 
    132137    Not: 
    133         if i < 7 
    134  
     138    {{{ 
     139    #!div style="font-size: 80%" 
     140    {{{#!python         
     141    if i < 7 
     142    }}} 
     143    }}} 
    135144Comments in the code 
    136145