I know I'm gonna feel dumb in the Morning....

yaipa h. yaipa at yahoo.com
Fri May 23 00:24:56 EDT 2003


Peter,

> 
> It will help if you learn to use the interactive prompt to 
> troubleshoot problems like this. 

What you see below IS the interactive prompt from 'idle fork'.
Should have checked the docs, but it just didn't occur to me
that sort() would return none. Long day.

-Al



Peter Hansen <peter at engcorp.com> wrote in message news:<3ECD7924.F1E969DA at engcorp.com>...
> "yaipa h." wrote:
> > 
> > What I really want to do is,
> > 
> >     for f in _fromDict.keys().sort():
> > 
> > But that fails, so then I try this...
> > 
> > >>> ==================== Code Snippet ===========================
> >       fLst = []
> >       fLst = _fromDict.keys().sort()
> > 
> >    # Now convert each From Object against the entire list of fromObjects
> >    for f in fLst:
> > 
> > >>> ==================== PROGRAM START ===========================
> > 
> > Traceback (most recent call last):
> >   File "C:\jDev\cs-171\project\cs171\ctt.py", line 124, in -toplevel-
> >     for f in fLst:
> > TypeError: iteration over non-sequence
> > 
> > Now I've made 'fLst' a list explicitly. Sooooo why doesn't this work?
> 
> It will help if you learn to use the interactive prompt to 
> troubleshoot problems like this.  In this case, after you 
> typed the above few lines, you could ask Python to just show
> you what fLst contains, and you'd quickly realize that it is
> *not* in fact a list, as you believe, after the sort.  Shortly
> after that you'd discover that sort() returns None...
> 
> -Peter




More information about the Python-list mailing list