In the meantime, I've been working on that name 'variable' the CS types keep using, spinning it different [sic], so that in Python we think of 'variable' as meaning the user makes up the name out of the blue (that's what's so variable about it, we're not even thinking about "contents" (what's that?)).
This is suitable for a day when unicode strings are getting very *not* Latin-1 in some contexts, so seem even more variable than usual, given our humble past of 128 then 256 (extended!) possible characters (punctuation, carriage return, little bell (ding! -- later a beep)). So when a Pythonista comes to C in CS wanting to learn the rope (pointers to pointers etc.), a prof might have to work extra hard to reinstill that old fashioned idea of a "variable" being "a container" of something (weird), a notion somewhat alien to those most competent in Python. Analogy: a kitchen coffee mug with a fun logo, design or slogan on the "outside" (topologically, said mug is a donut, something with one hole and one outside surface (irrelevant aside, but might come in handy)). A Python student looks at the mug and says, "hey, that's a cool variable" (admiring the picture of some wolf-horse or whatever). A C student says "what do you mean, it's still empty?" The C student calls the mug "a variable" because of all the wonderful stuff we might but "inside" the mug (strange huh? -- welcome to the wonderful world of K&R, MMX etc.). Kirby On Wed, May 21, 2008 at 7:47 AM, David MacQuigg <[EMAIL PROTECTED]> wrote: > At 06:35 PM 5/20/2008 -0700, Warren Sande wrote: > >>Putting aside the "pass-by-X" question, a beginner asks: >> >>"If I do A = (something) then B = A then I change A, does B also >>change?" >> >>And the answer, again, is "It depends." For mutable types, yes, for >>immutable types, no. And that's a sticky thing to get into for a beginner >>who is just learning what variables (names) are about. > > At this point, I would immediately stop using vague words like "change", and > try to find words with a more precise meaning, like "re-bind" and "modify". > "Re-assign" would be another possibility, but I see that "re-bind" is > commonly used in Python texts. Also, it is a less common word than > re-assign, so less likely to have other meanings. "Mutate" might be better > than "modify" for the same reason. > > Long before any discussion of parameter passing, students should have a firm > grasp of how variables work in Python, including the concepts of mutability > and rebinding. This is the model and terminology I suggest: > > variable:(name, pointer) --> object:(type, value, address) > > Other than the word "value", I don't see any confusion with any of these > terms. I haven't heard any suggestions for a better simple model. > > With this model in mind, the simple answer to the student's question is - "It > depends on whether you are modifying the object of variable A, or re-binding > A to some other object. > > -- Dave > > > > > _______________________________________________ > Edu-sig mailing list > Edu-sig@python.org > http://mail.python.org/mailman/listinfo/edu-sig > _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig