Explanation about for

Νικόλαος Κούρας nikos.kouras at gmail.com
Mon Jan 9 19:51:07 EST 2012

Στις 10 Ιανουαρίου 2012 1:42 π.μ., ο χρήστης Ian Kelly <
ian.g.kelly at gmail.com> έγραψε:

> > b) In the 2nd example we have for 'host, hits, agent, date in
> > dataset'. How does these 4 variables take their values out of dataset?
> > How dataset is being splitted?
> The second example works the same way as the first, except that
> instead of storing each row tuple in a single variable called row, it
> unpacks each tuple into four different variables named 'host', 'hits',
> 'agent', and 'date'.  These represent the values of the selected
> columns from the query, for each selected row.
if the MySQL query was:

cursor.execute( '''SELECT host, hits, agent, date FROM visitors WHERE pin =
%s ORDER BY date DESC''', pin )

can you help me imagine how the mysql database cursor that holds the query
results would look like? I must somehow visualize it in order to understand

Also what happend if the query was:
cursor.execute( '''SELECT host FROM visitors") ?

the result would have to be something likelike?

|somehost n|

So what values host, hits, agent, date would have in 'for host, hits,
agent, date in
 dataset' ? Every row has one string how can that be split in 4?

Excuse my english.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120110/8c1132ae/attachment-0001.html>

More information about the Python-list mailing list