There is already a question about checking whether an object is iterable, but sometimes I need to glimpse into what the iterable object looks like. For example, I found on SO that I can do the following:
sqlite_cursor.execute('SELECT * FROM mytable')
csv_writer.writerows(sqlite_cursor)
This works, but I cannot fathom how I could come up with this solution by myself without peeking into the db_cursor
object to determine whether it is a list of list (so that I can be given to writerows()
).
How do I peek into the object like that?