[Edu-sig] Fw: [Visualpython-users] Re: strange output

Arthur ajs@ix.netcom.com
Fri, 4 Oct 2002 09:31:33 -0400


Doing my morning rounds of annoying posts.

Thought I'd forward this up to edu-sig.

Bruce Sherwood, FWIW, was an influential advocate of the change in the "/"
operator (in that Guido referred to his position and classroom experience a
number of times in the course of the debate).  Bruce says without ambiguity
that his position is based on the fact that his students where thrown by the
fact that Python did not behave as a calculator.  Of course Bruce is a
physics instructor, with *no* particular interest in conveyuing programming
ideas to his students,  Even basic ones.  Except to the extent it effects
their ability to use one particular library - VPython.  Which by the way he
had very little to do with creating - at least in terms of actually writing
code.

All of which to me speaks to the better use of language in conducting
discussions around these points.  As far as I am aware nobody interested in
Python as an introductory *programming* language ever raised a serious
objection to the "/" operator behavior as it stood.  It concerned me that
the potential for a conflict of interests between different classes of
"novices" was never addressed in the debate.  Novices were newbies, were
non-programmers.  But the distinction of one's with an eye toward truly
learning programming, and ones with no interest in getting below the top
surface of scripting a little ditty or two, were discussed as if they were
somehow one class of folk.


----- Original Message -----
From: "Arthur" <ajs@ix.netcom.com>
To: "Bruce Sherwood" <basherwo@unity.ncsu.edu>; "vpusers"
<visualpython-users@lists.sourceforge.net>
Sent: Friday, October 04, 2002 9:13 AM
Subject: Re: [Visualpython-users] Re: strange output


> I think it worth supplementing Bruce's analysis with the solution to what
> was trying to be accomplished by
>
> rininitial = ball.pos
>
> I believe either:
>
> rinitial = ball.pos[:]
>
> or
>
> rinitial =copy(ball.pos)
>
> would get one to where one is trying to go.
>
> [:] returns a complete "slice" of the list.
> copy, of course, a copy of the list.
>
> In either case rinitial is no longer an additional name for ball.pos, but
an
> object independant of it, which will not be modified upon the modification
> of ball.pos.
>
> I think I have this right.  Corrections welcome.
>
> Art
> ----- Original Message -----
> From: "Bruce Sherwood" <basherwo@unity.ncsu.edu>
> To: "vpusers" <visualpython-users@lists.sourceforge.net>
> Sent: Friday, October 04, 2002 8:16 AM
> Subject: [Visualpython-users] Re: strange output
>
>
> > A VPython user sent me a small program that behaved oddly, and I thought
I
> > should share my analysis, since it involves an aspect of Python that is
> > subtle and may be missed in early study of the language. Fortunately it
> > rarely bites students writing computational physics programs!
> >
> > Early in the program the user said "rinitial = ball.pos" which means
> "assign
> > an additional name to ball.pos, so that in the future one can refer to
the
> > ball's position either by the label (name) ball.pos or the label (name)
> > rinitial". You can have lots of names pasted onto the same thing. The
> puzzle
> > for the user was that later in the program (after moving the ball
around),
> > printing rinitial showed the new value of ball.pos, not the initial
value.
> >
> > This multiple labeling has consequences only with "mutable" objects such
> as
> > lists -- objects whose values can be changed in situ. For example, if
you
> > say "a = 5" and then "b = a", and then say "a = 7", b will still have
the
> > value 5. When you assign 7 to a, you create a new object ("7") and
attach
> > the label "a" to it, so b continues to be a label for the object "5".
> >
> > But with "rinitial = ball.pos", you can actually change ball.pos without
> > creating a new object. For example, you might say "ball.pos.y = 7" in
> which
> > case the 2nd element in the ball.pos list has changed (without affecting
> the
> > other two elements). Since rinitial is a label for ball.pos, printing
> > rinitial shows you the new value of ball.pos.
> >
> > A list such as [1,2,3] is mutable. The Visual vectors are mutable. A
> 'tuple'
> > such as (1,2,3) is not mutable. Constants such as 3 or pi or a string
such
> > as 'cat' are not mutable.
> >
> > Needless to say, it took me a while to pay attention to "mutability" as
an
> > important property of Python objects!
> >
> > Bruce
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Visualpython-users mailing list
> > Visualpython-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/visualpython-users
> >
>