Breaking Out

Jay O'Connor joconnor at cybermesa.com
Fri Aug 23 23:08:47 EDT 2002


In article <tm1dmu44s6eah59fod8st9kmu68svfnimp at 4ax.com>, "Simon Faulkner"
<news at titanic.co.uk> wrote:

> What is the polite way to skip to the end of a long if statement?
> 
> if x ==y:
>   blah
>   blah
>   blah
>   blah
>   blah
>   blah
>   I WANT OUT!
>   blah
>   blah
>   blah
>   blah

You could put your code in a function and return early.

def foo(x,y):
	blah
	blah
	blah
	if not something:
		return
	blah blah
	blah
	return

if (x  ==y):
	foo()

Take care,
-- 
Jay O'Connor
joconnor at cybermesa.com
http://www.r4h.org/r4hsoftware



More information about the Python-list mailing list