Re/Unresolved bug?

Terry Reedy tjreedy at udel.edu
Sun Jun 29 13:09:31 EDT 2003


"Xavier" <sabu at pure-elite.org> wrote in message
news:mailman.1056845806.26609.python-list at python.org...
> Steven,
>
> Thanks for your reply.  Here is the exact, waiting to be fixed code:
> http://sabu.net/routekill.py

Suggestion: Put one "global METHOD, TARGETFILE, SINGLEIP, <etc>"
statement after "def main()" and remove all the others buried within
if blocks within a for block within an outer if block (and any past
where I read).

Reason: variables within a function are unconditionally local or
global within a particular function.  They cannot be one thing here
and the other elsewhere depending on which conditional statements are
true.  So the standard (and tested) place for a global statement is at
the top of the function.  There is no possible advantage to your
unusual placement and the now obvious possible disadvantage that it
confuses the compiler, even if technically legal.

Terry J. Reedy






More information about the Python-list mailing list