[Tutor] Compile Only
Kent Johnson
kent37 at tds.net
Thu Jan 27 14:20:32 CET 2005
If your program is written so it doesn't do anything when imported, you could use
> python -c "import myprogram"
myprogram.py should have a structure like this:
def main():
# do something...
if __name__ == '__main__':
main()
The "if __name__ ..." prevents the module from doing anything when it is imported; main() will only
be run when the module is run directly.
Kent
jhomme wrote:
> -----Original message-----
> From: "Alan Gauld" alan.gauld at freenet.co.uk
> Date: Thu, 27 Jan 2005 05:08:07 -0500
> To: "Chad Crabtree" flaxeater at yahoo.com
> Subject: Re: [Tutor] Syntax Check
>
>
>>>Does anyone happen to know how to turn of the syntax checking in
>>>python? I've been working on a module driven preprocessor but I'd
>>>like to not have to use comment strings.
>>
>>So don't use them! They aren't mandatory.
>>I'm not sure I understand youir problem? Why would turning
>>off syntax checking ever help?
>>
>>Alan G.
>>_______________________________________________
>>Tutor maillist - Tutor at python.org
>>http://mail.python.org/mailman/listinfo/tutor
>
> Hi,
>>From the command line, is there a way to run Python against a program so that it stops after it compiles even if the syntax is OK?
>
> Thanks.
>
> Jim
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list