On Fri, Aug 29, 2003 at 08:33:40AM -0500, Ron Johnson wrote: > On Thu, 2003-08-28 at 14:07, Pigeon wrote: > > > > - There isn't an explicit end-of-block delimiter. A tab to start a > > block; what ends it? A tab that isn't there? Yuck. > > As a long-time Python programmer, I must say, "Huh?". What's > so hard about this: > i = 1 > for i in range(10): > i = i * i > print i
Actually, that's quite a good example. Expectations lead me to
misinterpret that on my first pass: initially it looks like the
standard for loop to print squares of numbers from 1 to 10 that comes
shortly after "Hello world" in the introduction to more or less any
language, slightly misindented and missing the termination of the for
loop. But it isn't, is it - it throws away all the intermediate squares
and only prints the last one.
(runs it to check conclusions)
Oh, that's interesting - the for loop's running from 0 to 9, so it
prints "81", not "100".
(makes a guess)
...and our standard print-squares-from-1-to-10 example seems to be:
for i in range(1,11):
i = i * i
print i
> You'd get used to The Python Way really quickly. Everyone does.
Sure, familiarity counts for a lot, as the above example illustrates.
> > Guess I'll be sticking to C for a while yet...
>
> Try Python. You might like it. Really!
Given that my guess of how to make the for loop run from 1 to 10 was
right first time without looking at any docs, I'm inclined to believe
you may have a point there!
--
Pigeon
Be kind to pigeons
Get my GPG key here: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x21C61F7F
pgp00000.pgp
Description: PGP signature

