what is wrong with this line? while (line = workfile.readline()) != "":
Samuel A. Falvo II
kc5tja at dolphin.openprojects.net
Tue May 22 16:49:27 EDT 2001
On Tue, 22 May 2001 14:07:44 -0600, erudite wrote:
>Thank you all for your responses. Question though. Is there some sort of
>advantage to not allowing statements where a expressions is expected?
I think the idea was to make the language as easy to read for beginning
programmers as possible, without sacrificing the power of the language.
>> An alternative way to write the loop:
>>
>> line = workfile.readline()
>> while line != "" :
>> <rest of loop here>
>> line = workfile.readline()
>>
>> IMO this is a poorer way of organizing the loop due to the redunancy
>> of the line containing the call to 'readline'.
While the second line may be redundant, the flow and intent of the loop is
more explicit and easier to read.
--
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA
More information about the Python-list
mailing list