Python Quiz
Grant Edwards
grante at visi.com
Wed Jul 16 11:15:47 EDT 2003
In article <3F156952.AD24AAB8 at engcorp.com>, Peter Hansen wrote:
>>> Of course, I'm not suggesting that whitespace is *meaningless*
>>> in Python outside of indentation... Python is much like C (and
>>> many, many others) in that regard.
>>
>> Note that Fortran (at least historic Fortran - not sure about
>> those upstart 9x variants) is *not* among the "many, many
>> others." One can write any of
>>
>> DO 10 I = something
>> DO10I = something
>> D O 1 0 I = something
>>
>> and leave it to the compiler to figure out whether you're
>> starting a DO-loop or assigning a value to the variable DO10I.
>
> If you are saying that you leave it up to the compiler to
> decide how to interpret any of the three above statements, then
> clearly whitespace is *not* meaningless.
IIRC (it's been a _long_ time) it's not up to the compiler. All
three of the above are required to be treated the same by the
compiler (a DO loop).
> It might be compiler-dependent or something, but no
> meaningless. Unless you are saying that on a given FORTRAN
> compiler, only one possible interpretation of all three
> statements above is possible.
I don't think it's "on a given FORTRAN compiler", I think it's
more like "according to the language definition for FORTRAN IV".
> That would be surprising.
Yup. I found a lot of things in FORTRAN surprising. Python is
so much nicer in that respect. Though I was recently surprised
that the remove() method for lists uses "==" and not "is" to
determine what to remove. It's documented that it works that
way. But, it wasn't what I excpected, and it took me a while to
figure out that it was using my class's __cmp__ method rather
than the object ID.
--
Grant Edwards grante Yow! Go on, EMOTE! I
at was RAISED on thought
visi.com balloons!!
More information about the Python-list
mailing list