SyntaxError: 'return' outside function

Melih Onvural melih.onvural at
Wed Jan 31 22:25:02 CET 2007

Has anyone seen this error before and been able to solve it? I can't
seem to find anything that leads to a solution. I found this post, but can't really understand it.
I've attached my code below to see if anything looks funny. It happens
at the very last return at the end. Thanks in advance,



	def legiturl(self, url):
	# this breaks down the url into 6 components to make sure it's
		t = urlparse.urlparse(url)

		if t[0] != 'http':
			return ""

        # remove URL fragments, but not URL
        if len(t[5]) > 0:
        	url = urlparse.urlunparse((t[0],t[1],t[2],"","",""))
        	t = urlparse.urlparse(url)

        # stupid parser sometimes leaves frag in path
        x = find(t[2], '#')
        if x >= 0:
        	return ""

More information about the Python-list mailing list