SyntaxError: 'return' outside function

Melih Onvural melih.onvural at gmail.com
Thu Feb 1 01:15:48 EST 2007


Thanks all, I did a massive make sure everything is indents and not
spaces across all of my files and now things are running much more
smoothly. I appreciate the responses.

--melih

On Jan 31, 4:49 pm, s... at pobox.com wrote:
>     Melih> Has anyone seen this error before and been able to solve it? I
>     Melih> can't seem to find anything that leads to a solution.
>
> Your code is incorrectly indented.  Try:
>
>     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 ""
>
> instead.  Note also the lack of a return at the end of the function.
>
> Skip





More information about the Python-list mailing list