Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82059
| Path | csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <i@introo.me> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'true,': 0.05; 'none,': 0.07; '[1,': 0.09; 'function:': 0.09; 'issue:': 0.09; 'subject:skip:c 10': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; '2],': 0.16; '[none,': 0.16; 'expression,': 0.16; 'ivan': 0.16; 'none.': 0.16; 'none]': 0.16; 'received:143': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'fine': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'getting': 0.31; 'yes.': 0.31; 'worked': 0.33; 'received:209.85': 0.35; 'subject:lists': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'var': 0.36; 'list': 0.37; 'received:209': 0.37; 'skip:[ 10': 0.38; 'content- disposition:inline': 0.62; 'to:addr:gmail.com': 0.65; 'within': 0.65; 'url:me': 0.69 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=uLKTYxJ/rcvqza38VgrfujkTnyQaHXLcS3iq2hE4Czw=; b=m7abqBJrap1vdafuhZ+eOv7AJePMbX/rinn1XeI6p7Yh7C4lQpL3KTABHDuXhQvNyh dhA2P6wtd1paxY5pGpSpDI+8mjm621o4V4n/liUIh/wrbrJ1/ZbcFBo5eI64tLTPC30f PHQ43u811zIt4Uzze71l/WQ00tSByaOSLyt6SUMCme43w+09zleQVAPsaEYs6htwC8oj 371NguuagsViq8Ew9zOzL31FO6y/oekd4AVPF254wMe2GSN2XeZDv0OXXkF9Yu1wNX7I aIqO8JLyM38MfmGDBQ3EKFu+IsT8oGUTLYwAjEvxWwImjU/YEEfr9YJrS1rrYb++oQQ5 LLqw== |
| X-Gm-Message-State | ALoCoQnWCKuPz6gCaaDVbvT/uWJz+1QS9Jv347I8z3IY05nWqC67E9Aw3rbKcoYyjv9Qx/8kU8wK |
| X-Received | by 10.68.134.164 with SMTP id pl4mr52241795pbb.128.1417965474108; Sun, 07 Dec 2014 07:17:54 -0800 (PST) |
| Date | Sun, 7 Dec 2014 23:17:49 +0800 |
| From | Shiyao Ma <i@introo.me> |
| To | Ivan Evstegneev <webmailgroups@gmail.com> |
| Subject | Re: Tuple of lists concatenation - function vs comprehension |
| References | <001a01d0122f$86b95480$942bfd80$@gmail.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Disposition | inline |
| In-Reply-To | <001a01d0122f$86b95480$942bfd80$@gmail.com> |
| User-Agent | All mail clients suck. This one just sucks less. |
| X-Info | Find me @introom on Freenode. Have beers! :) |
| 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.16671.1417965483.18130.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1417965483 news.xs4all.nl 2953 [2001:888:2000:d::a6]:50800 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:82059 |
Show key headers only | View raw
On 12/07, Ivan Evstegneev wrote: > Hello, > > When I have worked in Python shell (IDLE) I found this issue: > > >>>x = ([1, 2], [3, 4], [5, 6]) > >>>L = [] > >>>for I in x: > L.extend(i) > > >>>L > [1,2,3,4,5,6] > > But when I try to make comprehension using above expression, I get this: > > >>>x = ([1, 2], [3, 4], [5, 6]) > >>>L = [] > >>> [L.extend(i) for i in x] > [None, None, None] Yes. per the doc, list.extend() returns None. > > But this works fine within function: > > >>> def myfunc(): > x = ([1, 2], [3, 4], [5, 6]) > L = [] > [L.extend(i) for i in x] > print(L) > > >>>myfunc() > [1, 2, 3, 4, 5, 6] This is also so true, as you are print the var 'L'. > > The question is why I'm getting empty list while working with comprehension > in interactive console? You are also getting [None]*3 in comprenhension inside a function. -- Shiyao Ma http://introo.me
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Tuple of lists concatenation - function vs comprehension Shiyao Ma <i@introo.me> - 2014-12-07 23:17 +0800
csiph-web