[Python-Dev] pychecker on 2.2 current

Neal Norwitz neal@metaslash.com
Wed, 05 Dec 2001 20:28:43 -0500


"Fred L. Drake, Jr." wrote:
> 
> Neal Norwitz writes:
>  > mimetypes.py:405: No global (sys) found
>  >
>  > This is inside usage() which presumably should only be used internally.
>  > sys is imported if __name__ == '__main__'.
>  > So the problem can only be triggered if usage() is called 
>  > by external source.
>  >
>  > Possible fixes are:
>  >      sys could be locally imported in usage()
>  >      sys could be imported at the module scope
>  >      usage could be made _usage() to denote it's private
> 
>   I'll propose another fix, but I don't know what pychecker would
> say.  ;-)  I'd like to move the definition of usage() into the if
> __name__ == "__main__" block, in which case the problem goes away
> since there wouldn't be a usage() unless sys has been imported.
>   I'll check it in that way.  ;-)

I like your fix better than my suggestions. :-)
I thought pychecker would complain, but it's happy too. :-)

Neal