diff doc/v2_planning/coding_style.txt @ 1150:d7192e52653e

coding_style: Moved some elements to official API
author Olivier Delalleau <delallea@iro>
date Thu, 16 Sep 2010 17:00:58 -0400
parents f6011a2aff0b
children 0904dd74894d
line wrap: on
line diff
--- a/doc/v2_planning/coding_style.txt	Thu Sep 16 16:25:38 2010 -0400
+++ b/doc/v2_planning/coding_style.txt	Thu Sep 16 17:00:58 2010 -0400
@@ -292,43 +292,6 @@
 Some coding guidelines (work-in-progress from OD)
 -------------------------------------------------
 
-   * Avoid using lists if all you care about is iterating on something. Using
-     lists:
-        - uses more memory (and possibly more CPU if the code may break out of
-          the iteration)
-        - can lead to ugly code when converted to Python 3 with 2to3
-        - can have a different behavior if evaluating elements in the list has
-          side effects (if you want these side effects, make it explicit by
-          assigning the list to some variable before iterating on it)
-    
-    Iterative version       List version
-    my_dict.iterkeys()      my_dict.keys()
-    my_dict.itervalues()    my_dict.values()
-    my_dict.iteritems()     my_dict.items()
-    itertools.imap          map
-    itertools.ifilter       filter
-    itertools.izip          zip
-    xrange                  range
-    
-    * Use `in` on container objects instead of using class-specific methods.
-      It is easier to read and may allow you to use your code with different
-      container types.
-
-    Yes                         No
-    ---                         --
-    key in my_dict              my_dict.has_key(key)
-    sub_string in my_string     my_string.find(sub_string) >= 0
-
-
-   * Generally prefer list comprehensions to map / filter, as the former are
-     easier to read.
-    Yes:
-        non_comments = [line.strip() for line in my_file.readlines()
-                                     if not line.startswith('#')]
-    No:
-        non_comments = map(str.strip,
-                           filter(lambda line: not line.startswith('#'),
-                                  my_file.readlines()))
     
     * Use the `key` argument instead of `cmp` when sorting (for Python 3
       compatibility).