Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52962
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!novso.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 | <i.am.songoku@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'assignment': 0.07; 'subject:getting': 0.07; '[1,': 0.09; 'assigning': 0.09; 'python': 0.11; 'itself.': 0.14; 'assignment.': 0.16; 'output?': 0.16; 'subject:when': 0.16; '>>>': 0.22; 'example': 0.22; '>>>': 0.24; "shouldn't": 0.24; 'friends,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'anyone': 0.31; 'beginning': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; '8bit%:9': 0.36; 'like,': 0.36; 'subject:List': 0.36; 'var': 0.36; 'list': 0.37; 'same.': 0.38; 'to:addr:python-list': 0.38; 'explain': 0.39; '12,': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'entire': 0.61; 'here': 0.66; 'direct': 0.67 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=4Gv//pyJWFxXMaTvS+6P/XJUvP56ldOLIH/U9aicTPA=; b=HYwfBM6ofQjVp1OxUXw+Q0V3N37KtxOqQejP3yCzi8oiqccmBsOxreqkIEUV4N1qjV KmyuuhJLXXxM3WFWBfQBE4wQMp5oPjprhT4QzK0sZ5iK5CYkuZ2k7aVj8ARCnd2/Ylcj +NvMrVjFAGRYjDj5GonsoHkOxEMkTOLS84a5Gvj1gIT6suU15mU7DKl23/mEEP2NcCAe fKcx+3qK91d4DumkRlceEVRvKMWtOA+9Bq+wF2J9fKWlGj9AhAIJlWVjv9AwSH7PFVUN q8CxK6SlH/toGTJXQZTgKbXl0wikcASiuxoxvsp/eseRwNtL6Xdp0dAUiRTa99SedNAy wL0A== |
| MIME-Version | 1.0 |
| X-Received | by 10.194.75.165 with SMTP id d5mr5095388wjw.18.1377402747067; Sat, 24 Aug 2013 20:52:27 -0700 (PDT) |
| Date | Sun, 25 Aug 2013 09:22:27 +0530 |
| Subject | List getting extended when assigned to itself |
| From | Krishnan Shankar <i.am.songoku@gmail.com> |
| To | Python <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=047d7bb04bc273a34d04e4bd9103 |
| 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 | <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.206.1377402755.19984.python-list@python.org> (permalink) |
| Lines | 63 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1377402755 news.xs4all.nl 15892 [2001:888:2000:d::a6]:57881 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52962 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hi Python Friends, I came across an example which is as below, >>> var = [1, 12, 123, 1234] >>> var [1, 12, 123, 1234] >>> var[:0] [] >>> var[:0] = var >>> var [1, 12, 123, 1234, 1, 12, 123, 1234] >>> Here in var[:0] = var we are assigning an entire list to the beginning of itself. So shouldn't it be something like, [[1, 12, 123, 1234], 1, 12, 123, 1234] It happens when we do the below, >>> var = [1, 12, 123, 1234] >>> var[0] = var >>> var [[...], 12, 123, 1234] >>> Literally var[0] = var and var[:0] = var almost meens the same. But why is the difference in output? Can anyone explain what happens when slicing assignment and direct assignment. Regards, Krishnan
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
List getting extended when assigned to itself Krishnan Shankar <i.am.songoku@gmail.com> - 2013-08-25 09:22 +0530 Re: List getting extended when assigned to itself Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-25 05:31 +0000
csiph-web