why cannot assign to function call

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Jan 5 06:15:12 EST 2009


On Sun, 04 Jan 2009 22:55:09 -0600, Derek Martin wrote:

> On Sun, Jan 04, 2009 at 09:30:20PM -0500, Steve Holden wrote:
>> > I'm going to go out on a limb and assert that there's NO POSSIBLE WAY
>> > a student could intuit Python's variable assignment behavior, having
>> > never been exposed to that same behavior prior.  It needs to be
>> > taught.
>> > 
>> As does assignment of any kind.
> 
> I'm not sure that's true.  Having taken algebra prior to learning Basic,
> I intuitively understood what this program would do when I executed it,
> the first time I saw the code, and before I read the explanation:
> 
> 10 let x = 10
> 20 print x

Do you really thought of `x` as a named memory location where the bit 
pattern for the floating point value 10 is stored, with just the algebra 
knowledge!?  Isn't "Ah there the name `x` is bound to the value 10." more 
likely?  As it is the technically easier and IMHO more intuitive 
explanation when you go from math to programming.

> [Well, to be honest it's been a very long time since I've programmed in
> Pet BASIC, and the syntax may be wrong.  The point is, just as I did
> then, I am positive that you intuitively understand what the above is
> intended to do, even if it is not valid BASIC syntax -- because if you
> did not, we would not be having this discussion.]

Syntax is correct.  :-)  The ``let`` is optional in Commodore BASIC.

But where is the difference to

x = 10
print x

?  Wouldn't you have guessed what this Python program will do just the 
same?

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list