Hey all,
I use MySQLdb a lot when dealing with my webserver. I often find myself repeating the lines:
row = cursor.fetchone()
while row:
do_processing(row)
row = cursor.fetchone()
Somehow this strikes me as somewhat un-pythonic. Is there a better, one-line way to accomplish the same thing, along the lines of inline assignment in C:
while (row = do_fetch()) {
do_processing(row);
}
I've tried figuring out the syntax using list comprehensions, but I can't seem to figure it out. Any recommendations?
Thanks,
Erik