On Thu, 16 Jun 2005 07:36:18 -0400, Roy Smith <[EMAIL PROTECTED]> wrote:
>Andrea Griffini <[EMAIL PROTECTED]> wrote: >> That strings in python are immutable it's surely >> just a detail, and it's implementation specific, >> but this doesn't means it's not something you can >> ignore for a while. > >I disagree. It is indeed something you can ignore for a while. The first >program you teach somebody to write is going to be: > >print "Hello, world" I mean that the fact that strings are immutable is one key aspect that cannot be worked around. Python is this way and in this very fact is different from e.g. C++. The ripple effect that this very little "detail" can have is not local. There are design based on strings that just do not make sense in python for this fact. It's not something you can "fix" later... if you need mutability you must simply not use strings for that (and this can have a serious impact on the source code). Of course there are programs in which that strings are immutable or not is irrelevant. But if you don't know what are the implications (e.g. how "is" works for strings in python) and you still don't run into problems it's just pure luck. The normal reaction I observed is that when they find a problem the result is a "python is buggy" idea. >It would be a mistake to mention now that "Hello, world" is an immutable >object. That's just not important at this point in the learning process. >Eventually, you're going to have to introduce the concept of immutability. >That point may not be much beyond lesson 2 or so, but it doesn't have to be >lesson 1. I must agree *if* you're teaching python first. I also *completely* agree if you're doing this just to get the appetite. What I don't agree is that starting from this level and going up is a good approach (with lously placed bricks you'll just not be able to hold the construction). To be able to build you'll need to memorize without a rationalization too many "details" that just do not make sense if you start from an ideal python world. I also must note that I, as a fourteen, found terribly interesting the idea of programming a computer even if the only things I could do were for example turning on and off pixels (blocks?) on a screen with resolution 40x50. Probably nowdays unless you show them an antialiased texture mapped 3D floating torus with their name and face on it in live video they'll prefer exchanging stupid messages with the mobile phone instead. Andrea -- http://mail.python.org/mailman/listinfo/python-list