On Jun 14, 7:11 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
>
> > I'm using os.walk as follows:
>
> > (basedir, pathnames, files) = os.walk("results", topdown=True)
>
> > and I'm getting the error:
>
> > ValueError: too many values to unpack
>
> > From my googling, that means:
>
> > This is the standard message when Python tries to unpack a tuple
> > into fewer variables than are in the tuple.
>
> > From what I can see of the examples on the python site, I'm using it
> > correctly.  I have commas in my original code, and the "results"
> > directory exists and is directly under the directory from which my
> > script is run.
>
> > I'm assuming that 12 files (the number of files in the "results"
> > directory) is not too many for Python to handle!  ;-)
>
> > Is there any other reason I might get that error?
>
> os.walk is a generator so you need to make it a loop target:
>
> for basedir, pathnames, files in os.walk("results"):
>      #
>      # Do you work inside the loop
>      #
>
> -Larry

Thanks!
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to