Good code patterns in Python
Bob Gailer
bgailer at alum.rpi.edu
Tue Jul 1 14:20:42 EDT 2003
>Will Stuyvesant writes:
> > If you know that your source code is going to be used
> > later by others, then I feel that code with the pattern:
> >
> > if some_condition:
> > some_name = some_value
> > else:
> > some_name = other_value
> >
> > is often a mistake. Much better, safer, would be:
> >
> > some_name = some_value
> > if not some_condition:
> > some_name = other_value
This brings back the good old days of FORTRAN IV which had a
single-statement IF and no ELSE. Thus:
C = VALUE1
IF ( A .EQ. B) C = VALUE2
Notice the indentation. Cols 1-5 were reserved for line # and col 6 for the
continuation code. So Python is not the only indentation dependent
language. Nor is it the first to use indentation to convey structure.
Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.492 / Virus Database: 291 - Release Date: 6/24/2003
More information about the Python-list
mailing list