Request for feedback on my first Python program
Aahz
aahz at pythoncraft.com
Sun Jun 1 12:02:56 EDT 2003
In article <mailman.1054429562.11692.python-list at python.org>,
Sean Legassick <sean at datamage.net> wrote:
>In message <slrnbdeevn.694.andrew-usenet at athena.jcn.srcf.net>, Andrew
>Walkingshaw <andrew-usenet at lexical.org.uk> writes
>>
>>def isMeaningful(line):
>> if line != "" and line[0] != "#":
>> return True
>> else:
>> return False
>
>Yuck!
>
>def isMeaningful(line):
> return line != "" and line[0] != "#";
>
>No offence intended, but I've seen this too often in real code not to
>point out its redundancy here.
It is *NOT* redundant; it is making clear that True/False are the only
possible return values. With your rewrite, reading and understanding
the code is necessary to clarify the intent.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles: boring syntax, unsurprising semantics,
few automatic coercions, etc etc. But that's one of the things I like
about it." --Tim Peters on Python, 16 Sep 93
More information about the Python-list
mailing list