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?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <philip@semanchuk.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'instance,': 0.05; 'character,': 0.07; 'list)': 0.09; 'syntax': 0.11; 'am,': 0.13; 'wrote:': 0.15; '(sun,': 0.16; 'both.': 0.16; 'dictionaries': 0.16; 'nesting': 0.16; 'received:mindspring.com': 0.16; 'subject:database': 0.16; 'subject:wrong': 0.16; 'x-mailer:apple mail (2.1084)': 0.16; 'pm,': 0.16; '>>>': 0.16; 'header:In-Reply- To:1': 0.22; '(where': 0.23; 'dictionary': 0.23; 'structure': 0.23; 'libraries': 0.25; 'specify': 0.25; 'xml': 0.25; 'tables': 0.28; 'example': 0.30; 'match': 0.30; 'config': 0.30; 'nested': 0.30; 'tuples': 0.30; 'subject:?': 0.31; 'named': 0.32; 'andrew': 0.32; 'comment': 0.33; 'to:addr:python-list': 0.34; 'instead': 0.34; 'received:24': 0.34; 'agree': 0.35; 'charset:us-ascii': 0.36; 'file': 0.36; 'some': 0.37; 'but': 0.37; 'could': 0.37; 'another': 0.38; 'subject:: ': 0.38; 'problem.': 0.38; 'think': 0.38; 'header:Mime-Version:1': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'skip:d 20': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; '31,': 0.64; 'encoding,': 0.84; 'ini': 0.84; 'lightweight': 0.84; 'received:69.73': 0.84; 'skip:q 30': 0.84; 'subject:should': 0.84; 'difficult.': 0.91
Content-Type text/plain; charset=us-ascii
Mime-Version 1.0 (Apple Message framework v1084)
Subject Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong?
From Philip Semanchuk <philip@semanchuk.com>
In-Reply-To <MPG.289fd3d02c5b69cd989841@news.individual.de>
Date Sun, 31 Jul 2011 16:53:48 -0400
Content-Transfer-Encoding quoted-printable
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>
To Lista-Comp-Lang-Python list <python-list@python.org>
X-Mailer Apple Mail (2.1084)
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - deimos.nocdirect.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - semanchuk.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1701.1312149953.1164.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312149953 news.xs4all.nl 23864 [2001:888:2000:d::a6]:57256
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10636

Show key headers only | 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