Wednesday, October 22, 2014

Monday, August 4, 2014

Python for CSharp devs, Winston-Salem

From twitter


Friday, July 18, 2014

Tiny & Teensy: Some new stuff!

Objects in mirror are smaller than they appear


The Raspberry Pi is pretty small, even in a case. The new model B+ (pictured on the left) allows for a slightly smaller case size. Gone is the composite, but there are way more GPIO pins available through a 40 pin connector, and 4 USB ports are included. It does mean that you will need a redesigned case for the new model B+. Oh, and gone is the SD card sticking out, waiting to be bent out of function. The B+ has a micro SD slot.

I'll post more details as I explore the changes, and what it means for python modules and the GPIOs.

Smaller than tiny

At the last Project night, I worked on getting micro python compiled to install on the Teensy v.3.1 (pictured on the right). This is much smaller than I was expecting.

BTW, this only has 64KB of RAM, which is what an Apple ][e had way back when... And 256KB of ROM. But did I say Python??? Yep. I'll post a step by step pretty soon.

Thursday, June 19, 2014

South East Linux Fest, Python Represent


I'll be presenting at South East Linux Fest (SELF) 2014. According to the final schedule, it is tomorrow, Friday the 20th at 4PM. Right after that will be a BOF in that same room. Come by and talk *nix and Python.

Last year Python was pretty much absent from the conference. Yet it is quite focused on security, and Python is just the right tool for that kind of stuff.


That's one project among many I'll be talking about, bringing computing education to people who are usually left without.

Keep an eye on my twitter account and this blog for details. The core of the talk is about Brython.


Apparently, videos of talks will be available after the conference.


Tuesday, June 17, 2014

Slowing down time

Is there a machine?

Quite frankly, that's the only way I'll be able to get back into my old posting habits, if I can slow down time...

So, just briefly, tomorrow is project night in Winston Salem:

James is bringing a Parallela. Markus will probably have a Beaglebone black. And I'll have a Raspberry Pi. Perhaps some of that + duct tape and I can build a time lapse machine! (Nothing nefarious, in reality, just a security cam to keep an eye on the entrance, so visitors to the project night dont have to wait to long for somebody to come and open the door...)

Micro Python

While on the subject of embedded devices, what do you all think of micro python?


Tuesday, March 25, 2014

Upcoming Python talk

Brython: Not Celtic, Pythonic!

Over the past few years, I've had a few A-Ha! moments, as I host project nights, mentor individuals and conduct workshops.

The latest was in front of a large classroom. That's when I realized I didn't have to explain what a shell or a command line was. So what is the Python punchline? It is one of the many anecdotes I'll cover in my talk @ TriPython this week in the Raleigh / Durham area of NC.


TriPython March meeting


Bull City Coworking location detail


Thursday, March 27th


Sunday, February 9, 2014

Python everywhere: #Brython 2.0

 It's alive

Wow, 15 months later and we are at Brython 2.0!

Changes in Brython version 2.0-20140209-164925

Backwards-incompatible change

For the sake of namespace isolation, by default, the name of functions and classes defined in Brython are no more available in Javascript global namespace. As a consequence, functions can't be called as event callbacks from HTML tags. For instance, if a function echo() is defined in a Brython script, the following inline code :

    <button onclick="echo()">

will result in a Javascript error such as "name echo is not defined" when the button is clicked

The solution is to define the event callback inside Brython code. The button must have an id :

    <button id="echo">

and the Brython code must include the line


Alternatively, to force the name "echo" into the global Javascript namespace, add it as an attribute of the window object :

    from browser import window
    window.echo = echo


  • - namespace isolation : in previous versions, the names defined in Brython core scripts were included in the global Javascript namespace, raising risks of conflict with names defined in Javascript programs or libraries. In this version, the only names included in the global Javascript namespace are __BRYTHON__ (used internally) and brython(), the function called on page load
  • - implement sys.implementation with values adapted for Brython
  • - allow syntax del (x, y, z)
  • - use Dan McDougall's pyminifier to reduce size of py_VFS.js
  • - make_dist generates a script brython_dist.js that can be used as a standalone distribution on a centralised server.


  • - add drop files demo (by Glenn Linderman) and French Python course (using module slideshow) to the gallery


  • - improved version of py_VFS.js by Billy Earney. py_VFS compiles the standard library to make imports faster. Now packs Python source with JSON instead of base64

Built-in modules

  • - browser : add attributes "window" and "document" as alias of respectively "win" and "doc"
  • - add a module browser/slideshow for PowerPoint-like slideshows in Brython, using a custom file format

Bug fixes

  • - issue #174 : string format character % has wrong precedence
  • - issue #175 : Functions should return None by default
  • - issue #183 : re.findall() broken
  • - issue #198 : operator precedence not defined for << and >>
  • - issue #206 : add <noscript> in case Javascript is disabled
  • - issue #208 : bug with try / else
  • - issue #209 : bug in ternary operator
  • - function definions must be evaluated only once, upon function definition
  • - bug with del a[:]
  • - bug with dir() called without arguments
  • - bug in map()
  • - bug with "func(x=1,)" ; "return +x" ; "func(10*-x)"
  • - bug in divmod and round
  • - bug in local_storage method keys()
  • - add attribute __doc__ to class and instance methods


  • - updated with the changes introduced in this version
  • - add documentation for the built-in module javascript
  • - translation in Spanish updated by Kiko Correoso

Monday, February 3, 2014

Run @PyCharm on #IllumOS and Solaris

Yes, it works

Go and check out Solaris Desktop for the details. The only challenge is in downloading the file. Then you will be able to enjoy PyCharm on IllumOS, stormOS, OpenIndiana, Solaris, Nexenta, SmartOS etc.


Python tip[8]

Tip #8

Always use a good bit of data to test your data driven apps. Don't rely only on nose testing. But where to get data? Fake it. Never underestimate the power of import random. But when you need more than numbers:

pip install fake-factory

You can also take a look at faker,, ForgeryPy (and many more on Then there is fake-data-generator. Or if you want a csv or sql, try

What it does: Although you could use real data, sometimes you don't have any. In fact, more than likely you probably wont be  able to generate a significant amount of data for weeks after going live with your web application. Or perhaps it is a desktop application and you'll never see the generated data. So just fake it. You need volume, and it's easy to create.

Another point to keep in mind is that using real data might be risky, depending on what it is. For sure you do not want real credit card numbers floating around on development instances.


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?