On Fri, 31 Mar 2006, Madan S. wrote:
> Daniel Rall said:
> > madan said:
> > +def error(s):
> > + """Subroutine to output an error and bail."""
> > + print >> sys.stderr, "%s: %s" % (NAME, s)
> > + sys.exit(1)
> > +
>
> > > We don't really need to relocate the definition of this function
> > > within the source file.
>
> I would think so too. But I tried with a sample pythong script. It
> expected the declaration of a function to preceed the
> usage. Wondering what could be different?!
As this is Python (rather than C), that's not required.
<soapbox>Stylistically speaking, when the implementation language
allows it, I prefer definition of high-level code to proceed
lower-level utility routines within a source file (e.g. public stuff
before private stuff), as I feel it results in more easily
understandable code for those who come later (it's top-down,
literally).</soapbox> Also, it avoids spurious diffs in the change
history. As usual, YMMV.
--
Daniel Rall
- application/pgp-signature attachment: stored
Received on Fri Mar 31 22:20:16 2006