Am 10.01.2012 10:02 schrieb Νικόλαος Κούρας:
-----------------------------------------------
| HOST    | HITS    | AGENT     | DATE |
-----------------------------------------------
| foo     | 7       | IE6       | 1/1/11 |
-----------------------------------------------
| bar     | 42      | Firefox   | 2/2/10 |
-----------------------------------------------
| baz     | 4       | Chrome    | 3/3/09 |
-----------------------------------------------

In this line:
for host, hits, agent, date in dataset:

'dataset' is one of the rows of the mysql result or the whole mysql
result set like the table above?

dataset is a cursor, representing the whole result set.

Iterating over it produces one row at each iteration step:

for row in dataset:
    ...

As each row consists of 4 fields, one iteration result is a tuple of 4 elements.

In this case,

for host, hits, agent, date in dataset:

is shorthand for

for anyunusedvariablename in dataset: # take complete row
    host, hits, agent, date = anyunusedvariablename # tuple unpacking
    del anyunusedvariablename # remove traces

exept that the said variable isn't created.


Thomas
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to