Python
From Healthcare Robotics Wiki
Contents |
HRL Coding Standards
- In general, we follow the official python coding standards (Python standards) but we will summarize here the relevant key points.
- Every indent is 4 spaces, replace all tabs with spaces.
- ClassName, method_name, _private_name
- Use classes sparingly, please try to define functions whenever possible.
- Instead of using inheritance, use duck typing (i.e. define interfaces based on conventions)
- With numpy, use matrices instead of arrays, all vectors should be column vectors.
- We use doxygen styled comments:
##
# some comments
# @param a is 3x1 point in coordinate frame C
# @param b is a 3x3 rotation matrix
# @return a 3x1 vector rotated by b
def my_function(a, b):
return b*a
learning python
- http://docs.python.org/
- http://docs.python.org/library/index.html
- python for programmers
- guido's guide (http://docs.python.org/tut/)
- dive into python (book) (http://www.diveintopython.org/toc/index.html)
- quick reference (http://rgruet.free.fr/PQR25/PQR2.5.html)
- ipython (http://ipython.scipy.org/moin/)
math, science, numerical, etc.
- numpy (http://numpy.scipy.org/)
- scipy (http://scipy.org/)
- matplotlib (http://matplotlib.sourceforge.net/): in ipython shell
- mayavi (http://code.enthought.com/projects/mayavi/)
opencv
- python specific documentation: PythonInterface, SWIG Python Interface
efficiency
- When you need buffering of some sort for logging/writing data, if speed is important use the deque data structure instead of lists: http://docs.python.org/library/collections.html#collections.deque