<div class="gmail_quote">On Mon, Dec 7, 2009 at 11:29 AM, Carsten Haese <span dir="ltr"><<a href="mailto:carsten.haese@gmail.com">carsten.haese@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Victor Subervi wrote:<br>
> I'll do my best to remember to do that from<br>
> now on to:<br>
><br>
>>>> allTrees = [{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {},<br>
> 'presCat2': {}}]<br>
>>>> level = 0<br>
>>>> tree = []<br>
>>>> for aTree in allTrees:<br>
> ...   for name in sorted(aTree.keys()):<br>
> ...     tree.append("%s%s" % ("\t" * level, name))<br>
> ...     print aTree([name], level + 1)<br>
> ...<br>
> Traceback (most recent call last):<br>
>   File "<stdin>", line 4, in ?<br>
> TypeError: 'dict' object is not callable<br>
>>>><br>
><br>
> So It would seem I need to either figure a way to coerce the dicts into<br>
> being tuples a la:<br>
> <a href="http://code.activestate.com/recipes/361668/" target="_blank">http://code.activestate.com/recipes/361668/</a><br>
> (which looks like a lot of work) or I need to supply tuples instead of<br>
> dicts.<br>
<br>
</div>No. You need to test the actual code you want to test. The code you<br>
typed manually has some very significant differences from the code you<br>
first posted. For example, one uses <<printTree(aTree[name], level +<br>
1)>>, and the other uses <<print aTree([name], level + 1)>>. The<br>
conclusions you are drawing from this test are meaningless guesses that<br>
have nothing to do with solving your actual problem.<br></blockquote><div><br>Another screw-up. Now that I'm at a computer where I can right click to paste the correctly copied code, it executed in the shell just fine. For whatever reason, the page itself no longer throws an error, although it's still not working properly. <br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
> The dicts come from here:<br>
><br>
> cursor.execute('select category from categories%s order by Category;' %<br>
> (store[0].upper() + store[1:]))<br>
> theTree = expand(cursor.fetchall())<br>
><br>
> which is the magical code supplied by the lister that does all the heavy<br>
> lifting but that I don't understand :-}<br>
> Suggestions?<br>
<br>
</div>Start by understanding the code you're using.<br></blockquote><div><br>Well, if you could point me in the right direction, it would be appreciated. I've tried googling this with no luck. Apparently, "expand" is not a well-documented term in python and, of course, it's an often-used term in English, which further confuses the issue. Yes, I would like to understand this code.<br>
TIA,<br>V<br></div></div>