Re:Python Cheat Sheet
by rmc on Tuesday September 04, 2012 @05:10PM
(#4476559)
Aren't all iterables objects? You can turn any object into an iterable by adding through __iter__ method IIRC
[ Parent
| on HN ]
Yes, but all objects are not iterables. If you list1.extend(object1) as the cheat sheet describes and object1 has no __iter__, it won't work. Likewise, you can iterate strings, so understanding the target of the iterable will be frustrating for list_of_strings.extend('newstring').
This is better described in python's native help documentation:
$ python
>>> help()
>>> list
searching for extend via '/extend': | extend(...)
| L.extend(iterable) -- extend list by appending elements from the iterable
Concise and correct.