PyChecker must execute script?

Just just at xs4all.nl
Wed Feb 5 23:09:59 CET 2003


In article <mailman.1044481572.29181.python-list at python.org>,
 Trent Mick <trentm at ActiveState.com> wrote:

> [Geoff Gerrietts wrote]
> > I believe PyChecker imports the modules, and analyzes the resulting
> > bytecode.
> 
> Yes.

What I don't understand is if it analyzes *byte code* then why it must 
do a full import? Wouldn't a plain compile() suffice then? There must be 
more to it.

> > If you have not included an "if __name__ == '__main__':" conditional,
> > then it is likely that importing the module and running it will be
> > fundamentally identical.
> 
> To be more specific. If you put all top-level executing code within a
>     if __name__ == "__main__":
>         # top-level code here
> block then you will be fine.

A class or def statement is also top-level executing code, as are any 
constant definitions and imports, so this definition is way to strict...

Just




More information about the Python-list mailing list