Pythonic way to condese my array

Dean Card mailer at forums.com
Wed Sep 20 00:33:01 EDT 2006


I have a list of dictionaries where each dictionary defines, among other 
things, a row and column number.  So, my list might look like this:
[{'row':1, 'column':1, otherdata}, {'row':1, 'column':2, 'otherdata}...]

This data is passed to flash and used there to create a grid of objects that 
are placed based on the row and column values.

For a given set of data I may have values column values in the range of 1, 9 
inclusive.

What I would like to do is take my list of dictionaries (like the one listed 
above) and shift the column numbers down to fill in missing values... 
example (only the column key,value pair is show for simplification):

[{'column':1}, {'column':2}, {'column', 4}, {'column': 8}, {'column':2}, 
{'column', 4}]

If this were the dataset... I would want to change all 4s to 3 and all 8s to 
4.  That way I end up with 1 ...  4 instead of 1, 2, 4, and 8.

Is there some slick way to do this?

Thanks





More information about the Python-list mailing list