Changes between Version 7 and Version 8 of DevGuide


Ignore:
Timestamp:
May 1, 2014, 1:58:23 PM (8 months ago)
Author:
hasienda
Comment:

more thoughts on coding style, maybe started a growing collection of hints?

Legend:

Unmodified
Added
Removed
Modified
  • DevGuide

    v7 v8  
    4242Authors are encouraged to conform to the [trac:TracDev/CodingStyle Trac Style Guide] and [http://legacy.python.org/dev/peps/pep-0008/ PEP-0008 style guide].
    4343
     44There are numerous other recommendations, and while some are mainly a matter of personal esthetic and preference, others are suggested for review and adoption:
     45 * [http://en.wikipedia.org/wiki/Yoda_conditions Yoda conditions] as [comment:ticket:11622:24 suggested by lkraav][[BR]]
     46 PROs:
     47  * makes comparisons more obvious by putting the constant up-front
     48  * erroneous assignment ('=' instead of '==') can't slip though unnoticed
     49 Example of common style:
     50 {{{
     51not req.authname or req.authname == 'anonymous'
     52 }}}
     53 same in 'Yoda condition' style
     54 {{{
     55not req.authname or 'anonymous' == req.authname
     56 }}}
     57
    4458== Assert Minimum Trac Version Requirement
    4559