Changes between Initial Version and Version 1 of DevelopmentPage/PythonLanguage


Ignore:
Timestamp:
Feb 11, 2010, 3:09:23 PM (14 years ago)
Author:
Michel Herquet
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DevelopmentPage/PythonLanguage

    v1 v1  
     1== Install Python ==
     2
     3We develop our code using Python 2.6, which is available for all platforms on http://www.python.org/download/. Installation of binaries is straightforward.
     4
     5Do not use another version, e.g. coming with Mac OSX or with your linux distribution. Those are often older an might not have all the required built-in functions.
     6
     7Do not use Python 3.X since the built-in libraries are still incomplete. We will move to 3.X when the Python project will recommend to do so.
     8
     9Comment: According to Pavel, RHEL5 will be the official Linux distribution at CERN for the next 3 years for the GRID machines. It appears it only comes with very old Python packages, essentially 2.4. This is an issue that should be discussed.
     10
     11== Optional: install matplotlib and scipy ==
     12
     13By default, we will (a priori) not require the user to have those tools installed to run MG5, but those might be useful for developing purposes.
     14
     15Scipy is necessary for all numerical calculations in python. You can find easy install instructions for all platforms on http://www.scipy.org/Installing_SciPy. You probably only need the numpy part of scipy.
     16
     17Matplotlib is necessary for plotting histograms, diagrams, ... You can find binaries for your platform on http://sourceforge.net/projects/matplotlib/.
     18
     19Please do not install a all-in-one python product (like Enthought for mac os), since the packages there are often not up-to-date.
     20
     21== Learn Python ==
     22
     23The best way to quickly learn Python for people with a previous experience in programming is probably:
     24
     25http://www.diveintopython.org/: a really nice free book, for advanced programmers, like you, who already know one language. Advanced topics like introspection, exceptions, unit tests, refactoring, functional programming, profiling, ... are nicely covered (with one concrete example in each case). The only problem: it has not been updated since 2004, but the language did not change that much since then. I think it's the best way to start.
     26
     27There are probably nice Python books on Amazon but I never bought one.
     28
     29For reference, the only relevant link is: http://docs.python.org/index.html
     30
     31The PDF quick reference http://rgruet.free.fr/PQR26/PQR2.6_modern_a4.pdf could also deserve a free spot on your desk during the next months
     32
     33For more advanced subjects:
     34
     35How to integrate C routines: http://www.penzilla.net/tutorials/python/swig/
     36
     37How to integrate F routines: for example: http://www.scipy.org/Cookbook/F2Py
     38
     39A success story for scientific programming in Python : http://www.adass.org/adass/proceedings/adass99/O3-02/
     40
     41== Optional: learn Numpy and Matplotlib ==
     42
     43For Numpy: you can learn to play with “arrays” (the basic object in Numpy) here: http://www.scipy.org/Tentative_NumPy_Tutorial
     44
     45For Matplotlib: the simplest way is to look at the example gallery http://matplotlib.sourceforge.net/gallery.html to find something which looks like what you want, and to adapt the corresponding code.
     46
     47== Write PEP-8 compliant Python code ==
     48
     49The PEP-8 document (http://python.org/dev/peps/pep-0008/) is often seen as the default format specification for Python. It is quite long to read, and almost impossible to remember. An easy way is to mimic a nicely formatted code. Print this one page PDF: http://wwd.ca/stuff/pep8_cheat.pdf and keep it close to your desktop, to see how your code should look like.