We were at La Cantine on May 21th 2012 in Paris for the "PyCon.us Replay session".
La Cantine is a coworking space where hackers, artists, students and so on can meet and work. It also organises some meetings and conferences about digital culture, computer science, ...
On May 21th 2012, it was a dev day about Python. "Would you like to have more PyCon?" is a french wordplay where PyCon sounds like Picon, a french "apéritif" which traditionally accompanies beer. A good thing because the meeting began at 6:30 PM! Presentations and demonstrations were about some Python projects presented at PyCon 2012 in Santa Clara (California) last March. The original pycon presentations are accessible on pyvideo.org.
PDB Introduction
By Gael Pasgrimaud (@gawel_).
pdb is the well-known Python debugger. Gael showed us how to easily use this almost-mandatory tool when you develop in Python. As with the gdb debugger, you can stop the execution at a breakpoint, walk up the stack, print the value of local variables or modify temporarily some local variables.
The best way to define a breakpoint in your source code, it's to write:
import pdb; pdb.set_trace()
Insert that where you would like pdb to stop. Then, you can step trough the code with s, c or n commands. See help for more information. Following, the help command in pdb command-line interpreter:
(Pdb) help Documented commands (type help <topic>): ======================================== EOF bt cont enable jump pp run unt a c continue exit l q s until alias cl d h list quit step up args clear debug help n r tbreak w b commands disable ignore next restart u whatis break condition down j p return unalias where Miscellaneous help topics: ========================== exec pdb
It is also possible to invoke the module pdb when you run a Python script such as:
$> python -m pdb my_script.py
Pyramid
By Alexis Metereau (@ametaireau).
Pyramid is an open source Python web framework from Pylons Project. It concentrates on providing fast, high-quality solutions to the fundamental problems of creating a web application:
- the mapping of URLs to code ;
- templating ;
- security and serving static assets.
The framework allows to choose different approaches according the simplicity//feature tradeoff that the programmer need. Alexis, from the French team of Services Mozilla, is working with it on a daily basis and seemed happy to use it. He told us that he uses Pyramid more as web Python library than a web framework.
Circus
By Benoit Chesneau (@benoitc).
Circus is a process watcher and runner. Python scripts, via an API, or command-line interface can be used to manage and monitor multiple processes.
A very useful web application, called circushttpd, provides a way to monitor and manage Circus through the web. Circus uses zeromq, a well-known tool used at Logilab.
matplotlib demo
This session was a well prepared and funny live demonstration by Julien Tayon of matplotlib, the Python 2D plotting library . He showed us some quick and easy stuff.
For instance, how to plot a sinus with a few code lines with matplotlib and NumPy:
import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) # A simple sinus. ax.plot(np.sin(np.arange(-10., 10., 0.05))) fig.show()
which gives:
You can make some fancier plots such as:
# A sinus and a fancy Cardioid. a = np.arange(-5., 5., 0.1) ax_sin = fig.add_subplot(211) ax_sin.plot(np.sin(a), '^-r', lw=1.5) ax_sin.set_title("A sinus") # Cardioid. ax_cardio = fig.add_subplot(212) x = 0.5 * (2. * np.cos(a) - np.cos(2 * a)) y = 0.5 * (2. * np.sin(a) - np.sin(2 * a)) ax_cardio.plot(x, y, '-og') ax_cardio.grid() ax_cardio.set_xlabel(r"$\frac{1}{2} (2 \cos{t} - \cos{2t})$", fontsize=16) fig.show()
where you can type some LaTeX equations as X label for instance.
The force of this plotting library is the gallery of several examples with piece of code. See the matplotlib gallery.
Using Python for robotics
Dimitri Merejkowsky reviewed how Python can be used to control and program Aldebaran's humanoid robot NAO.
Wrap up
Unfortunately, Olivier Grisel who was supposed to make three interesting presentations was not there. He was supposed to present :
- A demo about injecting arbitrary code and monitoring Python process with Pyrasite.
- Another demo about Interactive Data analysis with Pandas and the new IPython NoteBook.
- Wrap up : Distributed computation on cluster related project: IPython.parallel, picloud and Storm + Umbrella
Thanks to La Cantine and the different organisers for this friendly dev day.
- Interesting things seen at the Afpy Computer Camp
- About salt-ami-cloud-builder
- Reading SPE files
- PyConFr
- apycot-moved an Automated Pythonic Code Tester
Comments
Thanks for sharing. I would like to point out that Matplotlib is not only a "2D" plotting library: it does 3D as well.