Deeply nested dictionaries - should I look into a database or am I just doing it wrong?

Thorsten Kampe thorsten at thorstenkampe.de
Sun Jul 31 22:04:50 CEST 2011


* Andrew Berg (Sun, 31 Jul 2011 13:36:43 -0500)
> On 2011.07.31 02:41 AM, Thorsten Kampe wrote:
> > Another approach would be named tuples instead of dictionaries or
> > flat SQL tables.
> What would the advantage of that be?

QueueItem.x264['avs']['filter']['fft3d']['ffte'] would be 
QueueItem.x264.avs.filter.fft3d.ffte. I recently "migrated" from a 
syntax of - example - datetuple[fieldpositions['tm_year'][0]] (where 
fieldpositions was a dictionary containing a list) to 
datetuple.tm_year_start which is much more readable.

The advantage of a SQL(ite) database would be simple flat tables but 
accessing them would be more difficult.

Even a INI config file structure could match your problem.

Thorsten



More information about the Python-list mailing list