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


Groups > comp.lang.python > #52359

Re: Python Basic Doubt

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'programmer': 0.03; 'beginner': 0.05; 'url:pipermail': 0.05; 'subject:Python': 0.06; '(so': 0.07; 'assignment': 0.07; 'granted,': 0.07; 'important,': 0.07; 'memory.': 0.07; 'variables': 0.07; 'explanation': 0.09; 'immutable': 0.09; 'sentence': 0.09; 'variables.': 0.09; 'python': 0.11; 'stored': 0.12; 'posted': 0.15; '"is"': 0.16; "(it's": 0.16; 'c/c++': 0.16; 'crop': 0.16; 'distinct': 0.16; 'dump': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer,': 0.16; 'justified': 0.16; 'mutability': 0.16; 'mutable': 0.16; 'time.)': 0.16; 'two,': 0.16; 'unhelpful': 0.16; 'url:tutor': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'code.': 0.18; "python's": 0.19; 'fit': 0.20; 'aug': 0.22; 'fairly': 0.24; '(or': 0.24; 'right.': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'originally': 0.30; 'see,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'gary': 0.31; 'really,': 0.31; 'probably': 0.32; "we're": 0.32; 'url:python': 0.33; 'sense': 0.34; 'problem': 0.35; 'objects': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'url:org': 0.36; 'example,': 0.37; 'two': 0.37; 'starting': 0.37; 'step': 0.37; 'same.': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'url:mail': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'read': 0.60; 'continued': 0.60; 'is.': 0.60; 'most': 0.60; 'new': 0.61; "you're": 0.61; 'first': 0.61; 'places': 0.64; 'different': 0.65; 'needing': 0.65; 'talking': 0.65; 'note:': 0.66; 'between': 0.67; 'other.': 0.75; 'ear': 0.84; '2013': 0.98
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 :content-type; bh=guazHN/iYbgikD/DwUtu+hfjuqk8Lg71IyLYw00pwHk=; b=HMgYTZQ4+/wAEvEQ8wWZrO9ZdSm2eeoVzHjSNf5180zCynSfIflJt2MDZVwyI0bUSt JcYDdqgJw6oUE5eU4v+jCcECOQIq20rOjrkLzqL5yQtLr7ISiL6pS2V+CffcFhQiHQLT DWEKUdirQ+DCCPyjALLOrP5wISlZKexCtNUXdPRE1JaKDK27Qzr5xr3PahqWZH4zyd4R GWLgWoyWk+XINoCfLSPkuTi51yWodocJ3sCt+IQZv+G/oCMTmwtB++fyzpjWXOVHS/ON tStDRE5VVviub0cl8P2rLmOqR1isTzS7F+yjgZ4j/QhLjSyQqhTG+aLu32PSw8BFKDhs TG/w==
MIME-Version 1.0
X-Received by 10.220.43.19 with SMTP id u19mr3817639vce.3.1376196696434; Sat, 10 Aug 2013 21:51:36 -0700 (PDT)
In-Reply-To <52071320.9090308@islandtraining.com>
References <CAL0E0u6wO_UBniWoSpePvhKhPDG_nf4p1rqYYrGwzoHTqp6ZHA@mail.gmail.com> <20130810114040.6ac78fe8@bigbox.christie.dr> <52067FDA.2030908@gmail.com> <5206B527.6080700@islandtraining.com> <CAPTjJmoM=MU2eqa2i_5_RbveXMqScQqu_uFjonwdrZX7Vsc49g@mail.gmail.com> <5206DDED.8030506@islandtraining.com> <CAPTjJmrUGWnQ40iPiJtdKAB8WTbjRaM+bzUmukY6Cb4FvOi2JQ@mail.gmail.com> <5207034A.6070608@islandtraining.com> <CAPTjJmoj5K838vfjuEx9HGDuSb_Uq3=OckqksEk0YsM5Qb4P2w@mail.gmail.com> <52071320.9090308@islandtraining.com>
Date Sun, 11 Aug 2013 05:51:36 +0100
Subject Re: Python Basic Doubt
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.466.1376196698.1251.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1376196698 news.xs4all.nl 15874 [2001:888:2000:d::a6]:46215
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52359

Show key headers only | View raw


On Sun, Aug 11, 2013 at 5:29 AM, Gary Herron
<gary.herron@islandtraining.com> wrote:
> A beginner, on his first program or two, can understand 1, and perhaps
> parrot 2 without understanding (or needing to).   But the step from there to
> 3 is huge.  It's folly to dump that on a first-time programmer.  (It's
> probably even folly to dump that on a seasoned programmer just starting in
> Python.  I still remember not understanding the explanation for "is" when I
> first read it.  And it continued to make no sense until I had enough
> experience to understand the difference betwen C/C++ assignment to variables
> and Python's binding of variables.)

See, that's where the problem is. You will never grok the difference
between == and is if you're still thinking about C variables. (Though
you *might* be able to explain it by talking solely about char* and
the way two C strings can be the same but stored at different places
in memory. But that would be unhelpful most of the time.)

This is important *early* reading for a new Python programmer:

http://mail.python.org/pipermail/tutor/2010-December/080505.html

Note that it was originally posted on python-tutor, so it was
definitely aimed at the inexperienced.

> On 08/10/2013 08:43 PM, Chris Angelico wrote:
> Granted, English is a poor litmus test for code. But in this
> particular example, we're talking about immutable types (simple
> integers), where value and identity are practically the same. A Python
> implementation would be perfectly justified in interning *every*
> integer, in which case the 'is' would work perfectly here. The
> distinction between the two is important when the objects are mutable
> (so they have an identity that's distinct from their current values).
>
>
> Granted.  But please note:  There is *nothing* in that sentence which is fit
> for a beginner programmer.  ... "immutable", "value/identity", "interning"
> ...  In one ear and out the other. :-)

Right. This isn't my explanation of 'is' and '=='; it's my explanation
of why it's important to HAVE an explanation of the aforementioned. :)
Though the difference between value and identity is significant and
important, and mutability is bound to crop up fairly early on; so
really, it's only the concept of interning that would be really
advanced.

ChrisA

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


Thread

Re: Python Basic Doubt Chris Angelico <rosuav@gmail.com> - 2013-08-11 05:51 +0100

csiph-web