Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18759
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'assign': 0.04; 'python': 0.08; 'combines': 0.09; 'host,': 0.09; 'iterate': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'tuple': 0.09; '(tuple)': 0.16; '42,': 0.16; 'iteration,': 0.16; 'only?': 0.16; 'row': 0.16; 'substituting': 0.16; 'then:': 0.16; 'unpack': 0.16; 'wrote': 0.22; 'elements': 0.29; 'lines': 0.30; 'equivalent': 0.31; 'skip:( 20': 0.31; 'header:X-Complaints-To:1': 0.33; 'to:addr:python-list': 0.34; 'set.': 0.34; 'uses': 0.36; 'two': 0.37; 'but': 0.37; 'received:org': 0.38; 'represent': 0.39; 'to:addr:python.org': 0.40; 'frank': 0.64; 'received:41': 0.71; 'time?': 0.73; 'agent,': 0.91; 'technique': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | "Frank Millman" <frank@chagford.com> |
| Subject | Re: Explanation about for |
| Date | Tue, 10 Jan 2012 15:39:14 +0200 |
| References | <e1a94d90-57b4-4f6c-be9a-bef08f978639@h13g2000vbn.googlegroups.com><CALwzidmkSPAQBUxHTUWdoj+QKTR91UO_EPoMxr+2G+Qcy4PZdw@mail.gmail.com><CAGeFqcC=hc5xMgwqLAbdMR=cCdjYVhAbQvS9yeaxMH=o766_mA@mail.gmail.com><mailman.4567.1326157923.27778.python-list@python.org><581e9a24-f948-4fc4-ae28-227d6d526780@n6g2000vbg.googlegroups.com><jeh5jf$l7q$1@r03.glglgl.gl> <afd612b7-2366-40be-badf-13c97655f72d@o12g2000vbd.googlegroups.com> |
| X-Gmane-NNTP-Posting-Host | 41-133-114-227.dsl.mweb.co.za |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.3790.4657 |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.3790.4913 |
| X-RFC2646 | Format=Flowed; Original |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4595.1326202781.27778.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1326202781 news.xs4all.nl 6926 [2001:888:2000:d::a6]:38129 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18759 |
Show key headers only | View raw
"???????? ??????" <nikos.kouras@gmail.com> wrote in message
news:afd612b7-2366-40be-badf-13c97655f72d@o12g2000vbd.googlegroups.com...
>
> So that means that
>
> for host, hits, agent, date in dataset:
>
> is:
>
> for host, hits, agent, date in (foo,7,IE6,1/1/11)
>
> and then:
>
> for host, hits, agent, date in (bar,42,Firefox,2/2/10)
>
> and then:
>
> for host, hits, agent, date in (baz,4,Chrome,3/3/09)
>
>
> So 'dataset' is one row at each time?
> but we said that 'dataset' represent the whole result set.
> So isnt it wrong iam substituting it with one line per time only?
No. 'for host, hits, agent, date in dataset:' is equivalent to -
for row in dataset: # iterate over the cursor, return a single row (tuple)
for each iteration
host, hits, agent, date = row # unpack the tuple and assign the elements
to their own names
For the first iteration, row is the tuple ('foo', 7, 'IE6', '1/1/11')
For the next iteration, row is the tuple ('bar', 42, 'Firefox', '2/2/10')
For the next iteration, row is the tuple ('baz', 4, 'Chrome', '3/3/09')
The original line uses a python technique that combines these two lines into
one.
HTH
Frank Millman
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-09 15:23 -0800
Re: Explanation about for Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-09 16:42 -0700
Re: Explanation about for Chris Rebert <clp2@rebertia.com> - 2012-01-09 15:58 -0800
Re: Explanation about for Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-09 18:11 -0700
Re: Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-10 01:02 -0800
Re: Explanation about for Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-01-10 11:57 +0100
Re: Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-10 03:38 -0800
Re: Explanation about for Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-01-10 14:52 +0200
Re: Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-10 03:37 -0800
Re: Explanation about for "Frank Millman" <frank@chagford.com> - 2012-01-10 15:39 +0200
Re: Explanation about for Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-01-10 16:22 +0100
Re: Explanation about for RainyDay <andrei.avk@gmail.com> - 2012-01-11 14:39 -0800
Re: Explanation about for Nick Dokos <nicholas.dokos@hp.com> - 2012-01-10 10:24 -0500
Re: Explanation about for Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-11 14:50 -0800
csiph-web