[Svnmerge] [PATCH] svnmerge.py: all error handling to be doneusing the error() function

David James djames at collab.net
Fri Mar 31 12:25:54 PST 2006


On 3/31/06, Madan U S <madan at collab.net> 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?!

In Python, functions must be declared before they are called. If your
"main" function is only called at the bottom of the program, then you
can call any function in the program from the main function. For
example:
   def main():
      hello()
   def hello():
     print "hello"
   main()

If you move the call to "main()" up above the declaration of "hello",
then the program does not work. This is the difference.

Cheers,

David




--
David James -- http://www.cs.toronto.edu/~james




More information about the Svnmerge mailing list