Re: Too Many Values To Unpack

2009-11-21 Thread Steven D'Aprano
On Sat, 21 Nov 2009 21:06:08 -0800, Dennis Lee Bieber wrote: > I apparently thought "for ... in dictionary" would return (key, > value) pairs, but it appears that it only returns the key itself -- and > a single key can't be unpacked. > > Misleading error... too many /targets/ to unpa

Re: Too Many Values To Unpack

2009-11-21 Thread Gregory Ewing
Dennis Lee Bieber wrote: I apparently thought "for ... in dictionary" would return (key, value) pairs, but it appears that it only returns the key itself -- and a single key can't be unpacked. Misleading error... too many /targets/ to unpack... My guess is that the keys are st

Re: Too Many Values To Unpack

2009-11-21 Thread Carsten Haese
Victor Subervi wrote: > File "/var/www/html/angrynates.com/cart/catTree.py > ", line 25, in getChildren > for (nm, dt) in levelDict: > ValueError: too many values to unpack > > Please advise. I already explained what's causing this error. Read my first

Re: Too Many Values To Unpack

2009-11-21 Thread Victor Subervi
On Sat, Nov 21, 2009 at 2:10 AM, Dennis Lee Bieber wrote: >And my follow-up to that original thread stated that it /was/ > pseudo-code, not something tested. My goal was to illustrate the > general concepts of processing a recursive/nested data set stored in a > flat/relational table. >

Re: Too Many Values To Unpack

2009-11-20 Thread Carsten Haese
Victor Subervi wrote: > Now what I don't understand about the above code, provided by Dennis Lee > Bieber, is the "expand" statement. It's not a statement. It's a function. The function is defined in your code. Or rather, it's defined in the code that you copied from Dennis Lee Bieber, apparently.

Re: Too Many Values To Unpack

2009-11-20 Thread Victor Subervi
On Fri, Nov 20, 2009 at 12:14 PM, Shashank Singh < shashank.sunny.si...@gmail.com> wrote: > Are you sure your key values are 2-tuples in levelDict? > No. Here's some tweaked code: cursor.execute('select category from categories order by category') theTree = expand(cursor.fetchall())

Re: Too Many Values To Unpack

2009-11-20 Thread Carsten Haese
Victor Subervi wrote: > Hi; > At one point Dennis Lee Bieber helped me with the following slightly > modified code: > > [snippage...] > > def getChildren(levelDict, level = 0): > MAXLEVEL = 7 > if level > MAXLEVEL: > return #possibly the data has a cycle/loop > for (nm, dt) in levelDict:

Re: Too Many Values To Unpack

2009-11-20 Thread Shashank Singh
On Fri, Nov 20, 2009 at 9:15 PM, Victor Subervi wrote: > Hi; > At one point Dennis Lee Bieber helped me with the following slightly > modified code: > > #!/usr/bin/python > > import sys,os > sys.path.append(os.getcwd()) > import MySQLdb > from login import login > import re, string > > def printTr