Python defaultdict : d.get(key) vs d[key]

Today, I was trying to use Python’s defaultdict to handle a resume/experience management script that I’m building.

I noticed that  if you supply the default factory using Python defaultdict, e.g.

f = defaultdict(int)

and if you use the dict_get without providing a default value, you get a None value:

>>> f = defaultdict(int)
>>> f.get('happy')
>>> f.get('happy') + 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

but you will get the factory’s default value if you use the dict_subscript:

>>> f['happy']

then after using the dict_subscript, even when you do not provide the default value while using dict_get, you get the default value provided by the default factory:

>>> f.get('happy')

Python dictionary version  : 2.7

I am guessing that the dict_subscript updates the dictionary with the factory default value if you initialize the Python dictionary with the default_dict, but I might have to look into the dictobject.c to verify that.  This seems like a good place to start:

Posted in Uncategorized | Leave a comment

Debugging ParaView CMake mis-configuration issues

Before building, scan/read

Look for similar issues in paraview/paraview-developers mailing list

Look in *.cmake for the misconfigured CMake variable:

grep YOUR_VARIABLE_NAME * -rl | grep cmake

gives the name of the *.cmake file.
Look at what the CMake file expects as an input to the YOUR_VARIABLE_NAME. See for CMake macro conventions in order to understand what’s happening in your *.cmake
See for general information on CMake macros and functions

Posted in Uncategorized | Tagged , | Leave a comment

Quote of the day

QOTD:”Experience”, that elusive sought-after quality that almost every job description requires, can be broken down into a long list of pinpointed skills and facts such as the ability to translate an obscure linkage error to specific coding steps. 


Posted in Uncategorized | Leave a comment

ParaView VR Plugin state files

Addendum to

VRConnectionManager configuration deconstructed:

 <VRPNConnection name="device_name" address="device_name@server_address">
 <Button id="button_id" name="button_name"/>
 <Button id="button_id" name="button_name"/>
 <Tracker id="0" name="tracker_pv_name"/>

device_name: look in vrpn.cfg in the device server machine. The syntax for a particular device is usually

Vrpn_Class  device_name config_param1 config_param2

server_address : name of your machine on the LAN or your machine’s IP address.

button_name and tracker_pv_name:  the name of your device VRPN Connection instance in ParaView. This will be used later in VRInteractorStyles

VRInteractorStyles configuration deconstructed ( brackets [] denote optional):

 <Style class="interactor_style_class" [origin="CutFunction.Origin"] [normal="CutFunction.Normal"] [set_property=""]>
 <Button name="device_name.button_name"/>
 <Tracker name="device_name.tracker_pv_name"/>

<Style> element attributes :


This means that the interactor style controls RenderView1’s property. Comprehensive list of proxies and properties

The two following attributes will only work if you also have a Slice filter in your state file. Otherwise* the application crashes.


Interactor style controls the slice filter’s origin position.


Interactor style controls the slice filter’s orientation.

*(as of 07/05/2012)

Posted in Uncategorized | Tagged , | Leave a comment

Mailing list to Forum

Last week I went on an exercise to import the paraview-developers mailing list to nabble forum. It involved:

Quora gave me the idea on what to do:

Fun fact: the Perl scripts were written and the mailing list archives downloaded on the bus trip from Chapel Hill to Durham thanks to the free wifi on the Triangle Transit bus.

Here’s the result:

Sadly, I discovered today that such a service already exists:

Posted in Uncategorized | Tagged , , , , | Leave a comment

Windows: Building Qt From Source – NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’

I build Qt from source many, many times and often encounter this intermittent error:

NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’

Building Qt with configure and nmake takes at least an hour, and I have wasted many hours of my life rebuilding Qt (one of the suggestions that often works to fix the U1077 error is “Rerun nmake!” – but it doesn’t work all the time).

I finally found a solution that works (this time anyway, I will update this post if it fails in the future) requires building Qt in Safe Mode, and  uses jom for multi-core Qt building (way faster compilation! for multi-core processors anyway)

Reproduced verbatim from:

All credit goes to agent8261

I too had problems trying to install Qt 4.7.2 and integrating it with visual studio. When I tried to compile Qt using nmake I always got an error stating that some dll was in use. The actual dll changed every time. After about 2 days of searching and trying things, I fixed it, but I’m not at all sure what was wrong.
Hopefully this will help. Here are the exact steps I had to do in order to compile:
1: I uninstalled all the QT binaries.
2: I deleted the Qt folder.
3: I downloaded the Visual Studio Add-in []
4: I installed the visual studio add-in
5: I downloaded the Qt source code []
6: I created New folders c:\Qt\4.7.2-vc\ and extracted the source code to it.
7: I set the environment variables:
QTDIR = C:\Qt\4.7.2-vc\
QMAKESPEC = win32-msvc2010
8: I added to the Path variable:
cd C:\Qt\4.7.2-vc\bin
 If you set it up like I did, then you should be able to do:
C:\Qt\4.7.2-vc\configure.exe -help
from the windows cmd prompt.
9: I downloaded the lasts version of “jom”:
10: I created the folder C:\Qt\4.7.2-vc\jom extracted the jom files to it
11: I restarted windows then opened the VISUAL STUDIO command prompt and ran
 cd C:\Qt\4.7.2-vc
 configure -debug-and-release -opensource -platform win32-msvc2010
The configuration took awhile. After it was finished
I don’t know why this step was important, but I had to do the actual compilation in safe mode.
13: Open the VISUAL STUDIO command prompt and run
 cd C:\Qt\4.7.2-vc
 C:\Qt\4.7.2-vc\jom\jom.exe –j 8
8 is the number of CPU cores for my computer.
Building the file took a long time. By far the longest I have ever seen, but if finally finished.
Afterwards I had to open visual studio and configure the add-in. Below are the sites that helped me figure everything out.
FYI: I’m on windows 7, using visual studio 2010 ultimate (version 10.0.30319.1), running on a Intel i7(q720). I compiled 4.72 LGPL version of the QT framework. I am using the Visual Studio Qt add-in 1.1.9-1.
Posted in Uncategorized | Tagged , | 1 Comment

Unofficial Quora Follow Button on

If you have tried to add the Quora Follow Button to your blog,

you will notice that does not allow javascript embedding.

I created this Quora follow button

before I found Quora’s official recommendation (i.e. use html javascript adder)

FWIW I hosted the Gimp xcf file on Github:

See it in action.

For html embedding, I used:

<a href="http://goto_url" >
 <img src="img_source_url" />

Sorry, I don’t have Photoshop.

Posted in Uncategorized | Leave a comment