
April 29, 2009
11:42 p.m.
On 29Apr2009 20:47, Tarek Ziad? <ziade.tarek@gmail.com> wrote: | unless I missed it, I couldn't find a built-in to check if an object | is iterable, | | so I wrote this function : | | def iterable(ob): | try: | iter(ob) | except TypeError: | return False | return True This is actually a bad way of doing it. Suppose using the iterator has side effects? For example, "ob" might be a store-of-recent-messages, which empties after they have been collected. Or a file() attached to a pipe. -- Cameron Simpson <cs@zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/ Morning people may be respected, but night people are feared. - Bob Barker <Bob.Barker@MCI.Com>