This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年02月08日 19:03 by tormen, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg99059 - (view) | Author: (tormen) | Date: 2010年02月08日 19:03 | |
# python 3.1.1: myList = [] for item in myList: print( item ) # <<< works for item in myList.reverse(): # <<< breaks with: TypeError: 'NoneType' object is not iterable print( item ) # # But the reverse of an empty list should really be an empty list # ... or do I miss something here? |
|||
| msg99061 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2010年02月08日 19:06 | |
list.reverse() reverses the list *in place* and returns None, and "for item in None: ..." correctly raises a TypeError because None is not iterable. You either want for item in reversed(mylist): ... or mylist.reverse() for item in mylist: ... |
|||
| msg99082 - (view) | Author: (tormen) | Date: 2010年02月09日 01:31 | |
Thanks for your nice feedback even though my bug report was so stupid! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:57 | admin | set | github: 52134 |
| 2010年02月09日 01:31:53 | tormen | set | messages: + msg99082 |
| 2010年02月08日 19:06:54 | ezio.melotti | set | status: open -> closed priority: low nosy: + ezio.melotti messages: + msg99061 resolution: not a bug stage: resolved |
| 2010年02月08日 19:03:41 | tormen | create | |