Changes between Version 1 and Version 2 of CodingStyle

Show
Ignore:
Timestamp:
02/17/11 14:56:10 (2 years ago)
Author:
ian
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodingStyle

    v1 v2  
    44 
    55Urwid's current version aims to be compatible with Python versions 2.4 - 3.2.  These guidelines will help you write Python 2 code that will across those versions (with the help of 2to3) 
     6 
     7== from __future__ == 
     8 
     9We avoid use of ``from __future__`` imports in Urwid. 
     10 
     11This makes the code as much like normal Python 2 code as possible,  
     12allows people to easily move code in and out of the library and  
     13avoids surprising behaviour. 
    614 
    715== Strings and Binary Data == 
     
    1321 3. Binary data 
    1422 
    15 Unicode strings should be used for all text data in Urwid (mostly in example programs, but also in widgets that come with some default text).   
     23Unicode strings should be used for all text data in Urwid (mostly in example programs, but also in widgets that come with some default text).  
    1624 
    1725 * Use `u"My textual data"` for literal text data everywhere. 
     
    3038 * Use `B("bindata\x00\x42\xfe")` for literal binary data 
    3139 * Use `bytes()` for an empty binary string (eg. for joining a list of binary values) 
    32  * Use `bytes().rjust(x)` for x "space" characters as binary data 
     40 * Use `bytes().ljust(x)` for x "space" characters as binary data 
    3341 
     42== Unit Tests and Doctests == 
    3443 
     44When adding new code always include doctests (and documention!) where appropriate and unit tests for simple  
     45validation any tricky corner cases.  Add unit tests to ``urwid/tests.py`` and when creating a new module add 
     46it to the list of doctest modules in the same file.  To run the tests run: 
    3547 
     48{{{ 
     49python setup.py test 
     50}}} 
    3651 
    37