Sorry, I just found the
id = [conn.cursor() for x in range(100) ]
also works, so my concern will not be a problem anymore. Thanks for all of your answer, all of you are really fast.
===================== All,
id = [(conn.cursor(),x) for x in range(100) ]
>>> id
[(<sqlite3.Cursor object at 0x01D14DA0>, 0), (<sqlite3.Cursor object at 0x01D14DD0>, 1), (<sqlite3.Cursor object at 0x01D14E00>, 2), (<sqlite3.Cursor object at 0x01D14E30>, 3), (<sqlite3.Cursor object at 0x01D14EC0>, 4), (<sqlite3.Cursor object at 0x01D14EF0>, 5), <omitted>
but I do not need the id[1] col actually, and I do not want use the
for x in range(100):
id.append(conn.cursor())
for some reason, do you think I can use the list comprehension to get what I want? Also similiar question, if I want to invoke one function 100 times.
def foo():
pass
for x in range(100):
foo()
Can that "for" be rewrite to a list comprehensions style either?
Thanks!
====================