Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10636

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

Subject Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong?
From Philip Semanchuk <philip@semanchuk.com>
Date 2011-07-31 16:53 -0400
References <CAJ+TeoevaLW+PxixdLj9+tDkMZcGoxnp51K3PKWHQx4bbZt4Mg@mail.gmail.com> <mailman.1684.1312081856.1164.python-list@python.org> <MPG.289f25a5bb16d26998983f@news.individual.de> <mailman.1695.1312137417.1164.python-list@python.org> <MPG.289fd3d02c5b69cd989841@news.individual.de>
Newsgroups comp.lang.python
Message-ID <mailman.1701.1312149953.1164.python-list@python.org> (permalink)

Show all headers | View raw


On Jul 31, 2011, at 4:04 PM, Thorsten Kampe wrote:

> * 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.

INI files are OK for lightweight use, but I find them very fragile. Since there's no specification for them, libraries don't always agree on how to read them. For instance, some libraries treat # as the comment character, and others think it is ; and others accept both. There's no standard way to specify the encoding, and, as would be critical to the OP who is nesting dicts inside of dicts, not all INI file libraries accept nested sections.

To the OP -- if you're looking to write this to disk, I recommend XML or SQLite. 

JMHO,
Philip

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong? Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-30 22:10 -0500
  Re: Deeply nested dictionaries - should I look into a database or   am I just doing it wrong? Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-07-31 09:41 +0200
    Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong? Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-31 13:36 -0500
      Re: Deeply nested dictionaries - should I look into a database or   am I just doing it wrong? Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-07-31 22:04 +0200
        Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong? Philip Semanchuk <philip@semanchuk.com> - 2011-07-31 16:53 -0400
        Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong? Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-31 17:26 -0500
          Re: Deeply nested dictionaries - should I look into a database or   am I just doing it wrong? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-08-01 18:29 +1200
    Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong? Chris Rebert <clp2@rebertia.com> - 2011-07-31 12:51 -0700
    Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong? Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-31 15:34 -0500
      Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong? BlueBird <phil@freehackers.org> - 2011-08-02 02:17 -0700

csiph-web