[Tutor] Confused about error message
Kent Johnson
kent37 at tds.net
Mon Jul 4 03:50:08 CEST 2005
gelsey torres wrote:
> def unzip_file(filename):
> print "Unzipping file.."
> for file in filename:
> try:
> file = os.path.split(filename)[2]
> file += zlib.decompressobj()
>
> def main():
> address = raw_input("Enter the address of the site: ")
> url, filename = os.path.split(address) # remove path and keep the
> name of the original file
> get_file(address, filename, url)
> if fnmatch(filename, "*.zip"):
> unzip_file(filename)
> else:
> pass
>
> main()
> response = raw_input("Do you want to run the program again? (y/n): ")
> while (response == "y"):
> main()
> else:
> raw_input("\n\nPress enter to quit.")
>
> When I ran it to test main(), I got this error:
>
> File "file_downloader.py", line 25
> def main():
> ^
> SyntaxError: invalid syntax
You are missing the except: or finally: clause to the try in unzip_file().
Mysterious syntax errors are often incorrect indentation or (as in this case) something missing from the code before.
Kent
More information about the Tutor
mailing list