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

Chris Heald cheald45 at hotmail.com
Thu May 22 18:59:03 EDT 2003


>     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?

The return value of .sort() is "None". Sort mutates the object it is a
member of, sorting it. I think you want something like:

fLst = _fromDict.keys()
fLst.sort()
for f in fLst
    ...






More information about the Python-list mailing list