Monday, January 27, 2014


Raspberry Pi starter kit @ Radio Shack

Instant gratification

Back in December, I saw that Radio Shack started carrying the Raspberry Pi as a starter kit. It's actually more than a starter kit since it includes a prototyping board and components, for $99. I saw it was a sale tag, but didn't really look at the regular price.

Turns out the regular price is $129.99. That seems a bit high to me. What do you think?


Sunday, January 26, 2014

Analytics and Visualization

Analytics and Visualization

That's the talk I'll be doing tonight (monday the 27th) at Wake Forest University, in Winston Salem, NC. We'll talk trends, SAS, SPSS, Matlab, R, Python, Pandas, Excel, SQL, Manta, Vincent and all kinds of other stuff, all in 30 minutes. I love a challenge.

A twitter live feed

Hoping to tweet through the talk. Curious to see how that will go. Let's try #pythondata (pydata was shorter, but there's that conference...)

Those interested in attending in person:


Python tip[7]

Tip #7

Today's tip is quite basic, but will require time and effort to master:

Master the shell environment

What it does: Mac, Windows, Linux, BSD or Unix (or even something else). Whatever your operating system, become really good at using the command line, the shell. Bash, Powershell, ksh93 etc. Learn it. Else, it's like learning a bunch of words in a new language, but never learning the correct constructs. You might be able to communicate, but it'll never be very efficient. So go and find tutorials.

And then find the tools that'll make your life easier.

For example, *nix users, are you familiar with autojump (plus it's written in python)?

Windows users, did you know there is an equivalent Jump-Location for powershell?


Saturday, January 25, 2014

How projects nights are enablers for innovation

Project nights

Do you attend project nights organized by your local maker group, hackerspace, python user group, raspberry pi user group or other similar tech meet?

No? Why not, is it because there are none? Suggest it, then. Or perhaps it is because you do not have anything to present, or do not need help with any projects. Having said that...


Is not inventing something brand new from scratch. It's about standing on the shoulder of giants (a true, if somewhat overused metaphor). Taking many different things and bringing them together into a coherent entity, either a finished good, a software, a consumable or a building block for something else, in a new, innovative way.

It is not easy to achieve that. Are you familiar with all the bleeding and leading edge stuff happening in the tech space, in you area of expertise? Outside your area of expertise?

By attending project nights, and exchanging with people with different backgrounds and fields of expertise, the probability is much higher that you will come up with a solution, or even a new idea. But, more than that, it's at a personal level that you may benefit...

Personal scale innovation

While we all (well, a majority) would like to create the next big thing that will revolutionize the well being of mankind, truth is, what is more likely is to innovate at a personal level, household level or local community level. And your innovation or discussion may trigger another one, that is, if you are involved in some way in your community.

As an example, PYPTUG had a recent project night. One project was exploring the python picamera module. What started as that ended up creating two new projects, one based on Pi NoIR, the Raspberry Pi camera with no IR, as a way to detect heat loss (we'll see how well that works), and the other, as a helper to solder SMD devices.

Each month, there are many such moments of personal scale innovation. Perhaps not iPhone or Pebble (or Raspberry Pi) worldwide game changing innovation, but personal and local scale innovation.


Monday, January 20, 2014

Python tip[6]

Tip #6

Today's tip is in response to a great question on a local Linux user group:

python -m cProfile

What it does: It'll give you a breakdown per line of how much time each operation takes to execute. Normally, profiling is best done with something like dtrace, to minimize the impact on the run time, but the original question was about figuring out the time for each operation in a python script running on the Raspberry Pi (no dtrace...).

Assuming the following script (we'll use sleep to simulate different runtime, and not call the same function either, else each would be collased under one line on the report):
from time import sleep

def x():

def y():

def z():

print("outta here")
we get:
python -m cProfile
outta here
         8 function calls in 11.009 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000   11.009   11.009<module>)
        1    0.000    0.000    4.002    4.002
        1    0.000    0.000    5.005    5.005
        1    0.000    0.000    2.002    2.002
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
        3   11.009    3.670   11.009    3.670 {time.sleep}


Tuesday, January 14, 2014

Python tip[5]

Tip #5

Meet the triumvirate  of python interactive sessions:

help(), dir(), see()

So no doubt you use help, and probably dir, but you are probably wondering about see()... That's because it has to be installed first:

pip install see

What it does: Unless you speak native dunder (double underscore), dir's output can be a little overwhelming. For example, a dir on an int object (everything is an object in python...) gives us:

>>> dir(1)
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'conjugate', 'denominator', 'imag', 'numerator', 'real']

>>> from see import see
>>> see(1)
    +           -           *           /           //          %           **
    <<          >>          &           ^           |           +obj
    -obj        ~           <           <=          ==          !=          >
    >=          abs()       bool()      divmod()    float()     hash()
    help()      hex()       int()       long()      oct()       repr()
    str()       .conjugate()            .denominator            .imag
    .numerator  .real

A little more human readable, no? Oh, I'm about to hear the complaint about typing from see import see everytime you start up python. Time to go and check tip #2...


Friday, January 10, 2014

Python tip[4]

Tip #4

I was mentioning cppcheck on twitter, for those of us who also code in C/C++. I must admit I didn't start using it until I saw Alan (Coopersmith) using it on Xorg about a year ago. So, what do we have for python? Today I'll make a quick mention of Pylint. Install is simple, along the line of (adjust to your package manager):

sudo apt-get install pylint

Then you can go into a python project and do:


What it does: "Pylint is a tool that checks for errors in Python code, tries to enforce a coding standard and looks for bad code smells", according to It also gives your code an overall mark. It's a good idea to at least run it and look at the suggestions it offers.

Bonus: pylint includes pyreverse which allows one to generate a package and class diagram (UML) from source code. This works ok as long as the code is straight forward.


Tuesday, January 7, 2014

Python tip[3]

Tip #3

As you install new modules (say, with pip install) to support your Python application, add them to a requirements.txt file and do the same for your tests, as test_requirements.txt. Installation is then a simple:

pip install -r requirements.txt

What it does: It allows you to keep track of what packages are needed if you share your code, deploy it to other machines, or if you somehow have to rebuild your computer. You can also quickly test that the list is up to date by creating a virtualenv --no-site-packages, and then using a pip for that virtual environment to do the install.


Wednesday, January 1, 2014

Python tip[2]

Tip #2

In your home directory, in a file named put the imports you want to always have preloaded in python interactive mode:
from some_module import something
In your .bashrc or .profile, add:
What it does: When you login and open a terminal, the environment variable PYTHONSTARTUP will be set, and when you execute python (or bpython, too), the python interpreter will load whatever scripts are in PYTHONSTARTUP and be ready for you to use them without having to type them everytime. In this example, I could use functionality something of some_module right away.


2013 Raspberry Pi Python Adventures Review

More work, less social media

2013 kept me quite busy. I worked hard on Dion Research doing digital signage and interfacing with manufacturing equipment. I also took on a new position doing more Python development. And increased quite a bit the number of social events in the local Python community (actual physical events). What this means is that social media interaction slowed down some. This was even worse in the other languages, such as french, spanish and portuguese. The output there was quite spotty. Still, some of the articles and tweets I posted in 2013 were quite popular.

Most Popular

Hardware hacking and Python in the browser were the 2 most popular themes. In fact, in the #1 spot by far in terms of views in 2013 was an article on Brython from December 2012:

Now, a year later, Brython has been through many changes, including more javascript compatibility (and ongoing restructuring). You can learn more by checking out the Brython documentation.

Soliloquy: I spent a few weeks preparing something on Brython for PyCon, but the talk didn't get accepted, unfortunately, and has left me a bit ambivalent about conferences: Is my time better served building elaborate talks on open source projects I contribute to, for conferences I may not get invited to? Or spending the time on the actual projects coding, or even on this blog?

But not all is a loss for you, the reader, since I'll post some of that material on this blog in the coming months.

The #2 was this article on making your own GPIO cable for the still very popular Raspberry Pi:

Completing the podium at #3 for 2013 was:

Least Popular

The least popular articles were all administrative in nature, such as the announcement of the addition of a contact form. It is clear that very few are interested in these kinds of posts, and they will continue to stay at a minimum for 2014.


I just started yesterday a PTOT[D, W, M] (Python Tip Of The Day, Week, Month...). I'm curious to see how popular that will turn out to be. I'll also be introducing something new to help Windows users to get the most out of Python. Still, I recommend to get yourself a Raspberry Pi running Linux as a sidekick to your Windows machine, you'll be happier that way.

I'm also thinking about covering web.database, browser.local_storage, sqlalchemy, alembic and a few other database related themes.

What are some of the themes you'd like to hear about?