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, faker.py, ForgeryPy (and many more on pypi.python.org). Then there is fake-data-generator. Or if you want a csv or sql, try mockaroo.com

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?