Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '"this': 0.03; '"""': 0.07; 'assign': 0.07; 'list?': 0.07; 'memory.': 0.07; 'string': 0.09; 'immutable': 0.09; 'newly': 0.09; 'referenced': 0.09; 'cc:addr :python-list': 0.11; 'question.': 0.14; '>>': 0.16; 'cleaned': 0.16; 'concatenate': 0.16; 'email name:ben': 0.16; 'finney': 0.16; 'guess.': 0.16; 'immutability': 0.16; 'object)': 0.16; 'url:earth': 0.16; 'wa,': 0.16; 'wherein': 0.16; '\xc2\xa0i': 0.16; 'size,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'bit': 0.19; 'message-----': 0.19; 'thanks.': 0.20; 'memory': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'copied': 0.24; 'text.': 0.24; 'initial': 0.24; '(or': 0.24; 'question': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'world,': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'points': 0.29; 'subject:) ': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'changed.': 0.31; 'existence': 0.31; 'writes:': 0.31; 'up.': 0.33; 'url:python': 0.33; 'subject:the': 0.34; 'subject: (': 0.35; 'created': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'earth': 0.36; 'object,': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'two': 0.37; 'email addr:python.org': 0.37; 'clear': 0.37; 'being': 0.38; 'skip:& 10': 0.38; 'ben': 0.38; 'follows:': 0.38; 'question,': 0.38; 'skip:- 10': 0.38; 'explain': 0.39; 'skip:& 20': 0.39; 'does': 0.39; 'subject:': 0.39; 'subject:can': 0.39; 'enough': 0.39; 'url:mail': 0.40; 'even': 0.60; 'subject:"': 0.60; 'hope': 0.61; 'free': 0.61; 'new': 0.61; 'first': 0.61; 're:': 0.63; 'more': 0.64; 'different': 0.65; 'email name:python-list': 0.65; 'usa': 0.69; '\xc2\xa0\xc2\xa0': 0.74; 'day': 0.76; '\xe2\x80\x93': 0.77; 'prashanth': 0.84; 'subject:being': 0.84; '+1000': 0.91; 'drops': 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=RkAKaRJaE63UGqWV7bphIRsWjs9/qDCWpwLQTO57EMk=; b=Fn4OaKZeIlugxbYeEe0XvYVgYYSAV2PDmO3ruyaLBj8ntBfrLBFVbSPcI4BRZ6TCGD ZJjdmI5U9cUyTI4o3tDJFYomNVDVMeX1s3mPOIZ0Z4SU3pA33pvcPO9I6/HIlk65aLQ7 7Zj2nH1bq4lnRq9tc/+KFiv7nTKc3GyGcVvaVu4TgUlfy9TozG/Tcq/2CDLYD//N+tIE sRjNrzCfwbec9pwpbkArgOwLxE1w0BcoFlCj6acUj56dAtKR9Wv68WSWSYQv6XMKrCg7 RMzUmJqTNuqY29aWwlM/iL+TvQT5NLoovDF+o4Y0rM+h/vDwcIzBL6sZzq5trU1liOVG DGIw== MIME-Version: 1.0 X-Received: by 10.221.64.80 with SMTP id xh16mr6262673vcb.35.1401772853794; Mon, 02 Jun 2014 22:20:53 -0700 (PDT) In-Reply-To: References: <85a99u385y.fsf@benfinney.id.au> Date: Tue, 3 Jun 2014 10:50:53 +0530 Subject: Re: can someone explain the concept of "strings (or whatever) being immutable" From: "prashanth B.G" To: Deb Wyatt Content-Type: multipart/alternative; boundary=001a113351b2019e0b04fae7ada1 Cc: python-list@python.org, Ben Finney X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 194 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401772863 news.xs4all.nl 2883 [2001:888:2000:d::a6]:34500 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72470 --001a113351b2019e0b04fae7ada1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Deb, Immutability means that once "This is a string" is created in memory , the string cannot be changed. When we assign a_string with "A different string" this "A different string" is in a new memory location again (a new object) . "This is a string" and "A different string" are two different objects which are in existence which have been assigned to the variable a_string at different points in time. Now if "This is a string" is no longer referenced in the scope of the program , the reference count drops to zero at which point it is taken out of memory. Even though we perform a string concatenation and change the string from "A different string" to "A different string appended with some more words" , a new object is created , the initial string "A different string" is copied to this newly created object, "appended with some more words" are added to arrive at the final "A different string appended with some more words". The original "A different string" still remains until the point wherein it is not longer referenced after which it is cleaned up. Thanks. On Tue, Jun 3, 2014 at 10:36 AM, Deb Wyatt wrote: > > > > -----Original Message----- > > From: ben@benfinney.id.au > > Sent: Tue, 03 Jun 2014 14:54:01 +1000 > > To: python-list@python.org > > Subject: Re: can someone explain the concept of "strings (or whatever) > > being immutable" > > > > Deb Wyatt writes: > > > >> [no text] > > > > Deb, can you expand a bit =E2=80=93 and write the question in the body = of your > > message? It's not clear what you want explained. > > > > -- > > \ =E2=80=9CI hope if dogs ever take over the world, and they = chose a | > > `\ king, they don't just go by size, because I bet there are some = | > > _o__) Chihuahuas with some good ideas.=E2=80=9D =E2= =80=94Jack Handey | > > Ben Finney > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > that's strange that you see no text. The body of my email was as follows= : > > """a_string =3D "This is a string" > a_string is pointing to the above string > > now I change the value of a_string > a_string =3D "This string is different" > I understand that now a_string is pointing to a different string than it > was before, in a different location. > > my question is what happens to the original string?? Is it still in > memory somewhere, nameless? > """ > That was just the first question. What does immutable really mean if you > can add items to a list? and concatenate strings? I don't understand > enough to even ask a comprehensible question, I guess. > > > Thanks in advance, > Deb in WA, USA > > ____________________________________________________________ > FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! > Check it out at http://www.inbox.com/earth > > > -- > https://mail.python.org/mailman/listinfo/python-list > --=20 *****HAVE A NICE DAY ***** Prashanth --001a113351b2019e0b04fae7ada1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Deb,

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 Immutability means that once "This is a string" is created in= memory , the string cannot be changed. When we assign a_string with "= A different string" this "A different string" is in a new me= mory location again (a new object) . "This is a string" and "= ;A different string" are two different objects which are in existence = which have been assigned to the variable a_string at different points in ti= me.=C2=A0
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Now if =C2=A0"= ;This is a string" is no longer referenced in the scope of the program= , the reference count drops to zero at which point it is taken out of memo= ry. Even though we perform a string concatenation and change the string fro= m "A different string" to "A different string appended with = some more words" , a new object is created , the initial string "= A different string" is copied to this newly created object, "appe= nded with some more words" are added to arrive at the final "A di= fferent string appended with some more words". The original "A di= fferent string" still remains until the point wherein it is not longer= referenced after which it is cleaned up.

Thanks.

On Tue, Jun 3, 2014 at 10:36 AM, Deb Wyatt = <codemonkey@inbox.com> wrote:


> -----Original Message-----
> From: ben@benfinney.id.au > Sent: Tue, 03 Jun 2014 14:54:01 +1000
> To: python-list@python.org
> Subject: Re: can someone explain the concept of "strings (or what= ever)
> being immutable"
>
> Deb Wyatt <
codemonkey@inbox= .com> writes:
>
>> [no text]
>
> Deb, can you expand a bit =E2=80=93 and write the question in the body= of your
> message? It's not clear what you want explained.
>
> --
> =C2=A0\ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=9CI hope if dogs ever= take over the world, and they chose a |
> =C2=A0 `\ =C2=A0 =C2=A0king, they don't just go by size, because I= bet there are some |
> _o__) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 C= hihuahuas with some good ideas.=E2=80=9D =E2=80=94Jack Handey |
> Ben Finney
>
> --
> https://mail.python.org/mailman/listinfo/python-list
that's strange that you see no text. =C2=A0The body of my e= mail was as follows:

"""a_string =3D "This is a string"
a_string is pointing to the above string

now I change the value of a_string
a_string =3D "This string is different"
I understand that now a_string is pointing to a different string than it wa= s before, in a different location.

my question is what happens to the original string?? =C2=A0Is it still in m= emory somewhere, nameless?
"""
That was just the first question. =C2=A0What does immutable really me= an if you can add items to a list? and concatenate strings? =C2=A0I don'= ;t understand enough to even ask a comprehensible question, I guess.


Thanks in advance,
Deb in WA, USA

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
Check it out at ht= tp://www.inbox.com/earth


--
https://mail.python.org/mailman/listinfo/python-list



-- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 *****HAVE A NICE DAY ****= *
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 Prashanth
--001a113351b2019e0b04fae7ada1--