[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50019] trunk/blender/doc/python_api/rst/ info_best_practice.rst: spelling cleanup: spelling corrections from user zeffii on IRC.

Campbell Barton ideasman42 at gmail.com
Sun Aug 19 17:28:24 CEST 2012


Revision: 50019
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50019
Author:   campbellbarton
Date:     2012-08-19 15:28:24 +0000 (Sun, 19 Aug 2012)
Log Message:
-----------
spelling cleanup: spelling corrections from user zeffii on IRC.

Modified Paths:
--------------
    trunk/blender/doc/python_api/rst/info_best_practice.rst

Modified: trunk/blender/doc/python_api/rst/info_best_practice.rst
===================================================================
--- trunk/blender/doc/python_api/rst/info_best_practice.rst	2012-08-19 14:31:14 UTC (rev 50018)
+++ trunk/blender/doc/python_api/rst/info_best_practice.rst	2012-08-19 15:28:24 UTC (rev 50019)
@@ -75,7 +75,7 @@
 
 * layout.row()
 
-  Use row(), when you want more than 1 propertey in one line. 
+  Use row(), when you want more than 1 property in one line. 
   
   .. code-block:: python
 	 
@@ -145,7 +145,7 @@
 
 Modifying Lists
 ^^^^^^^^^^^^^^^
-In python we can add and remove from a list, This is slower when the list length is modified, especially at the start of the list, since all the data after the index of modification needs to be moved up or down 1 place.
+In python we can add and remove from a list, this is slower when the list length is modified, especially at the start of the list, since all the data after the index of modification needs to be moved up or down 1 place.
 
 The most simple way to add onto the end of the list is to use ``my_list.append(list_item)`` or ``my_list.extend(some_list)`` and the fastest way to remove an item is ``my_list.pop()`` or ``del my_list[-1]``.
 
@@ -154,13 +154,13 @@
 Sometimes its faster (but more memory hungry) to just rebuild the list.
 
 
-Say you want to remove all triangle faces in a list.
+Say you want to remove all triangular faces in a list.
 
 Rather than...
 
 .. code-block:: python
 
-   faces = mesh.faces[:]  # make a list copy of the meshes faces
+   faces = mesh.tessfaces[:]  # make a list copy of the meshes faces
    f_idx = len(faces)     # Loop backwards
    while f_idx:           # while the value is not 0
        f_idx -= 1
@@ -173,13 +173,13 @@
 
 .. code-block:: python
 
-   faces = [f for f in mesh.faces if len(f.vertices) != 3]
+   faces = [f for f in mesh.tessfaces if len(f.vertices) != 3]
 
 
 Adding List Items
 ^^^^^^^^^^^^^^^^^
 
-If you have a list that you want to add onto another list, rather then...
+If you have a list that you want to add onto another list, rather than...
 
 .. code-block:: python
 
@@ -205,6 +205,14 @@
        reverse_list.insert(0, list_item)
 
 
+Python provides more convenient ways to reverse a list using the slice method, but you may want to time this before relying on it too much:
+
+
+.. code-block:: python
+
+  some_reversed_list = some_list[::-1]
+
+
 Removing List Items
 ^^^^^^^^^^^^^^^^^^^
 
@@ -224,7 +232,7 @@
            my_list.pop(list_index)
 
 
-This example shows a fast way of removing items, for use in cases were where you can alter the list order without breaking the scripts functionality. This works by swapping 2 list items, so the item you remove is always last.
+This example shows a fast way of removing items, for use in cases where you can alter the list order without breaking the scripts functionality. This works by swapping 2 list items, so the item you remove is always last.
 
 .. code-block:: python
 
@@ -243,9 +251,9 @@
 Avoid Copying Lists
 ^^^^^^^^^^^^^^^^^^^
 
-When passing a list/dictionary to a function, it is faster to have the function modify the list rather then returning a new list so python doesn't have to duplicate the list in memory.
+When passing a list/dictionary to a function, it is faster to have the function modify the list rather than returning a new list so python doesn't have to duplicate the list in memory.
 
-Functions that modify a list in-place are more efficient then functions that create new lists.
+Functions that modify a list in-place are more efficient than functions that create new lists.
 
 
 This is generally slower so only use for functions when it makes sense not to modify the list in place.
@@ -273,22 +281,22 @@
 This really applies to any area of your code that involves a lot of string joining.
 
 
-Pythons string addition, *don't use if you can help it, especially when writing data in a loop.*
+Python’s string addition, *don't use if you can help it, especially when writing data in a loop.*
 
 >>> file.write(str1 + " " + str2 + " " + str3 + "\n")
 
 
-String formatting. Use this when you're writing string data from floats and int's
+String formatting. Use this when you're writing string data from floats and ints
 
 >>> file.write("%s %s %s\n" % (str1, str2, str3))
 
 
-Pythons string joining function. To join a list of strings
+Python’s string joining function. To join a list of strings
 
 >>> file.write(" ".join([str1, str2, str3, "\n"]))
 
 
-join is fastest on many strings, string formatting is quite fast too (better for converting data types). String arithmetic is slowest.
+join is fastest on many strings, `string formatting <http://docs.python.org/py3k/library/string.html#string-formatting>`_ is quite fast too (better for converting data types). String arithmetic is slowest.
 
 
 Parsing Strings (Import/Exporting)
@@ -296,12 +304,12 @@
 
 Since many file formats are ASCII, the way you parse/export strings can make a large difference in how fast your script runs.
 
-When importing strings to make into blender there are a few ways to parse the string.
+There are a few ways to parse strings when importing them into Blender.
 
 Parsing Numbers
 ^^^^^^^^^^^^^^^
 
-Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``,  float() will work for an int too but its faster to read ints with int().
+Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``,  float() will work for an int too but it's faster to read ints with int().
 
 Checking String Start/End
 ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -318,7 +326,7 @@
 
 my_string.endswith("foo_bar") can be used for line endings too.
 
-if your unsure whether the text is upper or lower case use lower or upper string function.
+If you are unsure whether the text is upper or lower case use ``lower()`` or ``upper()`` string function.
 
 >>> if line.lower().startswith("vert ")
 
@@ -328,7 +336,7 @@
 
 The **try** statement is useful to save time writing error checking code.
 
-However **try** is significantly slower then an **if** since an exception has to be set each time, so avoid using **try** in areas of your code that execute in a loop and runs many times.
+However **try** is significantly slower than an **if** since an exception has to be set each time, so avoid using **try** in areas of your code that execute in a loop and runs many times.
 
 There are cases where using **try** is faster than checking whether the condition will raise an error, so it is worth experimenting.
 
@@ -336,7 +344,7 @@
 Value Comparison
 ----------------
 
-Python has two ways to compare values ``a == b`` and ``a is b``, The difference is that ``==`` may run the objects comparison function ``__cmp__()`` where as ``is`` compares identity, that both variables reference the same item in memory. 
+Python has two ways to compare values ``a == b`` and ``a is b``, the difference is that ``==`` may run the objects comparison function ``__cmp__()`` whereas ``is`` compares identity, that both variables reference the same item in memory. 
 
 In cases where you know you are checking for the same value which is referenced from multiple places, ``is`` is faster.
 
@@ -344,7 +352,7 @@
 Time Your Code
 --------------
 
-While developing a script its good to time it to be aware of any changes in performance, this can be done simply.
+While developing a script it's good to time it to be aware of any changes in performance, this can be done simply.
 
 .. code-block:: python
 




More information about the Bf-blender-cvs mailing list