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


Groups > comp.lang.python > #24852

Re: a problem about "print"

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'immutable': 0.09; 'mutable': 0.09; 'objects.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thread': 0.11; 'alist': 0.16; 'cool.': 0.16; 'different?': 0.16; 'message- id:@dough.gmane.org': 0.16; 'morgan': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wed,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'bit': 0.21; 'names.': 0.22; 'subject:problem': 0.22; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'creating': 0.26; 'am,': 0.27; 'header:X-Complaints-To:1': 0.28; 'post': 0.28; "i'm": 0.29; 'lists': 0.31; 'code': 0.31; 'point': 0.31; 'problem.': 0.32; 'url:python': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'print': 0.32; 'doubt': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'list': 0.35; 'something': 0.35; 'received:org': 0.36; 'explain': 0.36; 'but': 0.36; 'url:org': 0.36; 'method': 0.36; 'should': 0.36; 'two': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'to:addr:python.org': 0.39; 'list,': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'different': 0.63; 'jul': 0.65; 'difficult,': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: a problem about "print"
Date Wed, 04 Jul 2012 09:24:48 +0100
References <CAEMsKDvjCqnetyhCA=F-jeOLdr-hcyYFN+DhO0OoaackE9mrkQ@mail.gmail.com> <CAEMsKDv0G40W61pbkUadzuRfe+eNVn5WS4iJDCioG+jTfeveYQ@mail.gmail.com> <CAJRADaOt3phGQ=afTy8TOX_qdtGv7zxfzvs2yp1S4GdgdZ=mkQ@mail.gmail.com> <CAEMsKDuejD6UcPrQ9LjiUxEEKjbY8Of7YS8O7kNo65hT3SerbQ@mail.gmail.com> <CAJRADaNqGOF+s-Eq_BNWh+4wsdPcVuttV0zWG1bmw_nyNFHM7Q@mail.gmail.com> <CAEMsKDv8vk0hkjPxd=xe=N7UmQzw9VYY1aTUaf3wk-CALEkJBw@mail.gmail.com> <4FF3F5F5.7070009@boscolini.eu>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-146-11-42.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20120614 Thunderbird/13.0.1
In-Reply-To <4FF3F5F5.7070009@boscolini.eu>
X-Antivirus avast! (VPS 120703-1, 03/07/2012), Outbound message
X-Antivirus-Status Clean
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.1784.1341390234.4697.python-list@python.org> (permalink)
Lines 82
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1341390235 news.xs4all.nl 6913 [2001:888:2000:d::a6]:54399
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:24852

Show key headers only | View raw


@Matteo, @Levi, please don't top post it makes following a thread very 
difficult, no other comments, TIA.

On 04/07/2012 08:51, Matteo Boscolo wrote:
> in the code2
>
> aList=[1,2,3,4,5,6,7,8,9,10]
> aList=str(aList) #<--- here you convert the list in a string
>
> print aList
> print aList[2] #<-- here you are printing the third caracter of the
> string '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]'  not the list '[1, 2, 3, 4, 5,
> 6, 7, 8, 9, 10]'
>
> regards
> Matteo
>
>
>
> Il 04/07/2012 09:28, levi nie ha scritto:
>> Hi,Harrison.
>> Your method is cool.
>> But i doubt this, if bList and aList just are attached to the same
>> List when i write bList=aList,but why the output of the following two
>> code are different?
>>
>> code1:
>> aList=[1,2,3,4,5,6,7,8,9,10]
>> bList=aList
>> bList=str(bList)
>> print aList
>> print aList[2]
>>
>> code2:
>> aList=[1,2,3,4,5,6,7,8,9,10]
>> aList=str(aList)
>> print aList
>> print aList[2]
>>
>> i'm puzzled now.
>>
>> 2012/7/4 Harrison Morgan <harrison.morgan@gmail.com
>> <mailto:harrison.morgan@gmail.com>>
>>
>>
>>
>>     On Wed, Jul 4, 2012 at 12:38 AM, levi nie <levinie001@gmail.com
>>     <mailto:levinie001@gmail.com>> wrote:
>>
>>         that's good,thanks.
>>         new problem.
>>         when i write
>>         bList=aList
>>         del bList[2]
>>         bList and aList both change,how can i make aList not changed?
>>
>>
>>
>>     Lists are mutable. That means that when you do bList = aList,
>>     you're just creating another reference to aList. They both point
>>     to the same list, just using different names. You should read up a
>>     bit on immutable vs. mutable objects. Here's something that I
>>     found that might explain it a bit better.
>>     http://henry.precheur.org/python/copy_list
>>
>>
>>
>>
>
>
>
>
>


-- 
Cheers.

Mark Lawrence.


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


Thread

Re: a problem about "print" Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-04 09:24 +0100

csiph-web