extending the break statement

Daniel Dittmar daniel at dittmar.net
Wed Oct 22 14:51:52 EDT 2003


Michele Simionato wrote:
> Is there a way of "ending" a module? I would like something like this:
> 
>   # mod.py
>   print 'something here'
>   end() # some mysterious function
>   print 'you should not get here'
[snipped part about not wanting to indent/dedent etc.)

Put the whole module into an if:

if 1:
     print 'something here'
     # want to break here
     print 'you should not get here'

You can then insert
if 0:
anywhere in the module to skip the rest without having to indent anything.

You can even insert another
if 1:
later to exclude only part of the module.

The same works in classes, where you also wanted a break statement.

Daniel





More information about the Python-list mailing list