beginner wrote: > Hi All, > > This is just a very simple question about a python trick. > > In perl, I can write __END__ in a file and the perl interpreter will > ignore everything below that line. This is very handy when testing my > program. Does python have something similar?
raise SystemExit() exits the program at that point (unless you catch the exception...) "import sys;sys.exit(0)" is basically another spelling of the same thing. It doesn't mean that the interpreter ignores the rest of the file though, so it will complain about syntax in the whole file. Since I don't usually write linear top-to-bottom scripts in Python, I don't really see the use of splitting a file in an interpreted top and an ignored bottom though. I'd suggest employing a test driven approach to development. Then you don't usually have big chunks of code that you don't want to run. All that's there works (almost)... See e.g. http://powertwenty.com/kpd/downloads/TestDrivenDevelopmentInPython.pdf -- http://mail.python.org/mailman/listinfo/python-list