Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80420
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <miloshzorica@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'column': 0.07; '(first': 0.09; '[1,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; "'b',": 0.16; "('b',": 0.16; "('c',": 0.16; '(second': 0.16; '1),': 0.16; '2),': 0.16; '3)]': 0.16; '7:58': 0.16; "[('a',": 0.16; 'code?': 0.16; 'iterator': 0.16; 'row)': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.18; 'advance.': 0.19; 'cc:addr:python.org': 0.22; 'fine': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'list:': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; "d'aprano": 0.31; 'piece': 0.31; 'produces': 0.31; 'steven': 0.31; 'url:python': 0.33; 'third': 0.33; 'except': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'nov': 0.38; 'url:library': 0.38; 'list,': 0.38; 'rather': 0.38; 'does': 0.39; 'bad': 0.39; 'url:mail': 0.40; 'read': 0.60; 'url:3': 0.61; 'first': 0.61; 'email addr:gmail.com': 0.63; 'zip': 0.64; 'skip:r 30': 0.69; 'special': 0.74; 'demand': 0.91; 'same,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=lVa0GT1ndho3EmNUcQCu8XxjNY0xNEjr2psC68BYLBI=; b=rY0+7wUX8Mnad36nh4jc3/5wtR9gbofc5UMzxPwmhBfKx0s4Z4RvM0Y+Fxx5f+DouT UBJ2R2yK05v1mUs46FtwnNrXu+ES4tyPWOi7eP8/6STwDT2+Nk9WYjqxp7SVK/kRGtQM 0NGN//MTRXqG/rlyfLGbNMytC2Bh570gw3P+V+HL9iPqSoaoWuLbyKmLsUoYH+Frds44 ccgMt6mNGEnFMWqk+sk5AaXoCll6hG/aajCgWqMtx+2Q1vRqwgwbD5dcA4D3sTErhtzs AjlPNNmaUO8fl6cBm+ZDjLTx2/wDlmc/0H1AwKykpocna5L3Ms4Cxb9uJBIqTgPXXTZR +jYw== |
| MIME-Version | 1.0 |
| X-Received | by 10.112.36.197 with SMTP id s5mr23235191lbj.30.1415531185766; Sun, 09 Nov 2014 03:06:25 -0800 (PST) |
| In-Reply-To | <545f48b9$0$13005$c3e8da3$5496439d@news.astraweb.com> |
| References | <baab02ae-09b4-4b9c-8e29-50e2581f9a7b@googlegroups.com> <545f48b9$0$13005$c3e8da3$5496439d@news.astraweb.com> |
| Date | Sun, 9 Nov 2014 08:06:25 -0300 |
| Subject | Re: What does zip mean? |
| From | milos zorica <miloshzorica@gmail.com> |
| To | "Steven D'Aprano" <steve+comp.lang.python@pearwood.info> |
| Content-Type | multipart/alternative; boundary=001a113433687f06b305076b09c9 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15595.1415531192.18130.python-list@python.org> (permalink) |
| Lines | 120 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1415531192 news.xs4all.nl 2878 [2001:888:2000:d::a6]:37520 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 7265 |
| X-Received-Body-CRC | 2522778470 |
| Xref | csiph.com comp.lang.python:80420 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
sorry my bad
On Sun, Nov 9, 2014 at 7:58 AM, Steven D'Aprano <
steve+comp.lang.python@pearwood.info> wrote:
> satishmlmlml@gmail.com wrote:
>
> > What does zip return in the following piece of code?
>
> Have you read the Fine Manual?
>
> In Python 2, zip returns a list:
>
> zip(['a', 'b', 'c'], [1, 2, 3])
>
> => [('a', 1), ('b', 2), ('c', 3)]
>
> https://docs.python.org/2/library/functions.html#zip
>
>
> In Python 3, zip does the same, except instead of a list, it returns a
> special iterator which produces the items on demand rather than in advance.
>
> https://docs.python.org/3/library/functions.html#zip
>
>
>
> > curs.execute('select * from people')
> > colnames = [desc[0] for desc in curs.description]
> > rowdicts = []
> > for row in curs.fetchall():
> > rowdicts.append(dict(zip(colnames, row)))
>
> zip(colnames, row) will return:
>
> (first column name, first item of row),
> (second column name, second item of row),
> (third column name, third item of row),
> etc.
>
>
>
> --
> Steven
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
Milos Zorica
+1 845 277 0549 | +1 786 471 4846
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What does zip mean? satishmlmlml@gmail.com - 2014-11-09 02:44 -0800
Re: What does zip mean? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-09 21:58 +1100
Re: What does zip mean? milos zorica <miloshzorica@gmail.com> - 2014-11-09 08:06 -0300
Re: What does zip mean? giacomo boffi <giacomo_boffi@inwind.it> - 2014-11-10 17:48 +0100
Re: What does zip mean? Grant Edwards <invalid@invalid.invalid> - 2014-11-10 17:19 +0000
Re: What does zip mean? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-11 10:04 +1300
Re: What does zip mean? Cameron Simpson <cs@zip.com.au> - 2014-11-11 07:36 +1100
Re: What does zip mean? Terry Reedy <tjreedy@udel.edu> - 2014-11-10 19:39 -0500
Re: What does zip mean? giacomo boffi <pecore@pascolo.net> - 2014-11-13 23:10 +0100
Re: What does zip mean? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-14 22:06 +1100
csiph-web