Array of dict or lists or ....?

Gabriel Genellina gagsl-py2 at
Wed Oct 8 03:35:20 CEST 2008

En Tue, 07 Oct 2008 23:15:54 -0300, Pat <Pat at> escribió:
> Dennis Lee Bieber wrote:
>> On Mon, 06 Oct 2008 19:45:07 -0400, Pat <Pat at> declaimed the
>> following in comp.lang.python:
>>> I can't figure out how to set up a Python data structure to read in  
>>> data that looks something like this (albeit somewhat simplified and  
>>> contrived):
>>> States
>>>     Counties
>>>       Schools
>>>         Classes
>>>            Max Allowed Students
>>>            Current enrolled Students
>>> Nebraska, Wabash, Newville, Math, 20, 0
>>> Nebraska, Wabash, Newville, Gym, 400, 0
>>> Nebraska, Tingo,  Newfille, Gym, 400, 0
>>> Ohio, Dinger, OldSchool, English, 10, 0
>>  	<snip>
>> The structure looks more suited to a database -- maybe SQLite since
>> the interface is supplied with the newer versions of Python (and
>> available for older versions).
> I don't understand why I need a database when it should just be a matter  
> of defining the data structure.  I used a fictional example to make it  
> easier to (hopefully) convey how the data is laid out.

You don't need a full-blown-multiuser-concurrent-petabyte-capable-server  
database, just one that does the job. SQLite is very small and comes with  
Python 2.5

> The Perl routine works fine and I'd like to emulate that behavior but  
> since I've just starting learning Python I don't know the syntax for  
> designing the data structure.  I would really appreciate it if someone  
> could point me in the right direction.

So none of the previously posted alternatives worked for you?

Gabriel Genellina

More information about the Python-list mailing list