Thursday, September 29, 2011

quick detour

I took a brief lull in activity at work to knock out another important piece of code in my case analysis program (not so much analysis right now - mostly just parsing).

Python lacks a #define statement so I can't alias words to numbers. I had really hoped to do this to pair column names (human readable) to numbers (parser readable).

Instead of:

#define OPENDATE 0
#define CLOSEDATE 1
#define NOTES 2

I am faced with just making them proper variables:

OPENDATE = 0
CLOSEDATE = 1
NOTES = 2

and so on.

I stumbled across a different solution I like in example 3.20: http://diveintopython.org/native_data_types/declaring_variables.html#odbchelper.multiassign

I'll flip a coin to decide which is more readable and then put it in. The code for returning a specific column is already in place. Took me longer than it should have - I've forgotten too much about Python in the past few months.

No comments:

Post a Comment