"Compile time" checking?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed Aug 10 16:42:50 EDT 2005
In <1123703058.378299.133980 at g47g2000cwa.googlegroups.com>, Qopit wrote:
> Now I'm running into another snag when checking some other code I have.
> Pychecker gets hung up on raw_input... it actually executes code
> rather than just checking it, it seems. For example, the snippet below
> hangs pychecker::
>
> #---
> while 1:
> x = raw_input("meh:")
> #---
>
> Curious.
AFAIK `pylint` tries to avoid running the code.
A common idiom to protect code from being executed, if the module is just
imported opposed to executed as main module, is to write::
def foo():
# some code
if __name__ == '__main__':
foo()
`__name__` is set to the module name if the module will be imported but to
'__main__' if the module is directly executed.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list