[Tutor] [Fwd: Re: Dictionary within a dictionary]

Marilyn Davis marilyn at deliberate.com
Sat Jun 14 02:05:41 CEST 2008


On Fri, June 13, 2008 4:09 pm, Alan Gauld wrote:

> "Marilyn Davis" <marilyn at deliberate.com> wrote
>
>
>> When see nested builtin data structures, I always think it's time to
>> think of making a few classes instead.
>
> It could be, especially if you are about to write a bunch of
> functions to access those structures. But equally if the structures
> accurately reflect the problem and acess does not require any complex
> processing then I'm happy to use the structures.
>
> In a case like this I'd still tend to move to a database rather
> than an OOP solution, although I might use classes to hold the returned
> data.

That sounds like the best plan.

>
> I'm still not clear why the OP wants to hold the data in
> memory.

I don't know either.  Maybe s/he wants to use shelve or something; maybe
s/he has not yet learned classes and databases.

So thank you for the reality check.

Marilyn Davis


>
> Alan G
>
>>
>> Python tutors, is this a good suggestion?
>>
>>
>> Marilyn Davis
>>
>>
>>>
>>>
>>> [{'id': <group id>,
>>> 'category': [{'id': <category id>,
>>> 'sub-category': [ {'id': <sub-category id>,
>>> 'title': <sub-category title>,
>>> 'is_selected': <True | False>
>>> }
>>> ...]
>>> 'title': <category title>,
>>> 'is_selected': <True | False>
>>> }
>>> ...]
>>> 'title': <group title>,
>>> 'is_selected': <True | False>,
>>> }
>>> ...]
>>>
>>>
>>>
>>> Reason for this is that I want to create a navigational menu for a
>>> web template so that when you click on group_id the value is sent and
>>> this pulls the 'categories' and when you click on the category then
>>> the sub- categories are listed.
>>>
>>> Thanks
>>> David
>>>
>>>
>>>
>>>
>>>
>>> __________________________________________________________
>>>
>>>
>>>
>>> Find out what Tiscali can do for you -
>>> http://www.tiscali.co.uk/services
>>>
>>>
>>>
>>> _______________________________________________
>>> Tutor maillist  -  Tutor at python.org
>>> http://mail.python.org/mailman/listinfo/tutor
>>>
>>
>>
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor






More information about the Tutor mailing list