3 ms·
Aren't all iterables objects? You can turn any object into an iterable by adding through __iter__ method IIRC
by rmc 14y ago
Aren't all iterables objects? You can turn any object into an iterable by adding through __iter__ method IIRC
- clinth 14y agoYes, 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.