Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107604

what is the difference between one-line-operation and 2-line-operation

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From oyster <lepto.python@gmail.com>
Newsgroups comp.lang.python
Subject what is the difference between one-line-operation and 2-line-operation
Date Mon, 25 Apr 2016 22:13:56 +0800
Lines 62
Message-ID <mailman.78.1461593638.32212.python-list@python.org> (permalink)
References <CACW-qXU_b9G3016m12FgqgUEhGE-QkioiXacQOCAHrRrVzbQPg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de i61Hot3bwqmA6UGwCkcVLQ1biEOB1FeE594r1SYyMLWg==
Return-Path <lepto.python@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.057
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; '[1,': 0.09; '[2,': 0.16; 'examples?': 0.16; 'py3': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:between': 0.16; 'to:name:python- list@python.org': 0.20; 'produces': 0.22; 'message- id:@mail.gmail.com': 0.27; 'function': 0.28; 'subject:what': 0.29; 'code': 0.30; 'says': 0.32; 'received:google.com': 0.35; 'so,': 0.35; 'text': 0.35; 'received:74.125.82': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'thanks': 0.37; 'difference': 0.38; 'skip:v 20': 0.38; 'subject:the': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'more': 0.63; 'between': 0.65; 'received:74.125.82.41': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=pUGwkSSi9Kf6ocfUDLr1fYgC8AArU04bg8H3d6LF6DI=; b=LaBCPkhDVFbSC+lL+1xCk3Hn3KD7AFoO0vC9W3ifuyNwaGQoOvVd/0kQn/EhGrEGPK R8EGqDaJ553wZHPTZ8/Smje5q16eGy6XhzgUiQjydoq3Zlm/4D2QaH8yb03juwWEssLG XuBjLXIPbN8bv/3TE1B90Sm9Mt57QnXApAwsOqD+RYJct7jCMl2bEMTM5/da+uVjewKn EXgur9s99r9WDX+M6JiI4xn0arlr9xYSihck9mLmai+o/5pYNe+haZuIz6mw3u5kM3a2 H2hRFGHVdzLem4Z6lBvWMcqhfpSntf5hX3cgdFWX3EiLbAaBZiFL2tnLboMToPrSJZbz 1KYA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=pUGwkSSi9Kf6ocfUDLr1fYgC8AArU04bg8H3d6LF6DI=; b=dPbFkSDt6yXpMUwjy4rETh6IbfuVbVYGOv+zTgDYk0yhlJmCLtMIXBCz2pvz3dYWgx K5S6sFrVafLPbToT2JYt+Fzd8UB2Qxj9Cacotinqi7s2pX7UVRh/TT2O127HJDham/Ti whemRMCkpXRvpPBz1I80OppQdLgVM7BFdtOq60SgQvkCCbEiwwGczeyiRRBsykxbtHNr KPkagqrSGu9c7KUynfCOv9lKRSTve2CXXAhdTTx2WOkh4nEXMeBCQuWHJ1aYwCKDKQfr gGhR8nVeFUMKXccLwpzX9tduzX1PGCdTlEFlMMJaK6P3JoJ0wmcmApuiQzi7NrvvXzYX sNRg==
X-Gm-Message-State AOPr4FW23vHwqhvOSat6jWaY3vMS7k36zIeAtyfVSWo7kBOekomKJbYe7mXlw487csn5/a/D0Btum854zQe7bQ==
X-Received by 10.28.54.157 with SMTP id y29mr12041912wmh.25.1461593636739; Mon, 25 Apr 2016 07:13:56 -0700 (PDT)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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>
X-Mailman-Original-Message-ID <CACW-qXU_b9G3016m12FgqgUEhGE-QkioiXacQOCAHrRrVzbQPg@mail.gmail.com>
Xref csiph.com comp.lang.python:107604

Show key headers only | View raw


for a simple code
[code]
vexList = [1, 2, 3]
print('vexList', list(vexList))

vexList=map(lambda e: e+1, vexList)
print('vexList', list(vexList))

vexList = list(vexList)
print('vexList', list(vexList))

vexList=map(lambda e: e*2,vexList)
print('vexList', list(vexList))
[/code]


py27 says
[quote]
('vexList', [1, 2, 3])
('vexList', [2, 3, 4])
('vexList', [2, 3, 4])
('vexList', [4, 6, 8])
[/quote]

but py34 says
[quote]
vexList [1, 2, 3]
vexList [2, 3, 4]
vexList []
vexList []
[/quote]

if I change the above code in to one line
[code]
vexList = [1, 2, 3]
print('vexList', list(vexList))

vexList=list(map(lambda e: e+1, vexList))
print('vexList', list(vexList))


vexList=map(lambda e: e*2,vexList)
print('vexList', list(vexList))
[/code]

then py27 and py34 get same verList
[quote]
('vexList', [1, 2, 3])
('vexList', [2, 3, 4])
('vexList', [4, 6, 8])
[/quote]

I found 'filter' function behaves likely

I found
type(map(lambda e: e, vexList))  is <type 'list'> in py2
type(map(lambda e: e, vexList)) is <class 'map'> in py3

so, what produces this difference between py2 and py3 in nature? is
there more examples? where can I find the text abiut his difference?

Thanks

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

what is the difference between one-line-operation and 2-line-operation oyster <lepto.python@gmail.com> - 2016-04-25 22:13 +0800
  Re: what is the difference between one-line-operation and 2-line-operation Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-04-25 17:42 +0300

csiph-web