SyntaxError: 'return' outside function

Melih Onvural melih.onvural at gmail.com
Wed Jan 31 16:25:02 EST 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
http://zope.org/Collectors/Zope/1809, 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,

--melih

===========Code========

	def legiturl(self, url):
	# this breaks down the url into 6 components to make sure it's
"legit"
		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