Re: [Tutor] search through a list
nephish said unto the world upon 02/07/2005 23:41: > hey there > i have a file that i want to read. > each line in the file is the name of a file. > the next line is how many lines are in that file. > > example of loglist.txt > > log1.txt > 232 > log2.txt > 332 > log3.txt > 223 > > so log1 is a text file that has 232 lines in it. > > ok, so what i want to do is read this file, see if the file i am looking > for is in it > and if so, i need to know how many lines are in the file. > > here is what i have so far. > > import os > > #get a list of Logs in logs folder > LogFiles = os.listdir('/home/nephish/Projects/Piv_GCI/logs') > > #open the loglist file and read the lines > LogList = open('home/nephish/Projects/Piv/logs/LogList.txt', 'r') > LogsRead = LogList.readlines() > > #see if there is a new log file. > for i in LogFiles: > if LogFiles[i] not in LogList: > #if there is a new log, open it and read the lines > StrName=(LogFiles[i]) > NewLog = open('/home/nephish/Projects/Piv_CGI/logs'+StrName,'r') > NewLogRead=NewLog.readlines() > #print the lines (testing only) > for x in NewLogRead: > print x > print '\n' > print '\n' #end for loop > else: #if the log file is not new, > > um this is where i am stuck. i need search the LogList for the name of > the name of the file in LogFiles and get the line number back so i can > use it to compare with how many lines are in the log file so i can only > process the data in the new lines ... does this make sense ? > > i need to find the item in a list, and when found, return the next line. > > any takers? > > thanks > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor It's late and I might not have completely understood the task. Warning given: So, you have a list of strings, and each is a line from your text file described at the top, right? If so, maybe this will meet your needs: >>> l_list = ['these are\n', 'just some lines\n', 'to test with\n', 'nothing to see\n'] >>> def line_finder(line_list, flag): flag = flag.strip() return_next = False for line in line_list: if return_next: return line.strip() else: if line.strip() == flag: return_next = True >>> line_finder(l_list, 'just some lines') 'to test with' >>> (If the line isn't found, the function returns None.) HTH, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] a question
when I type sys.ps2 after import sys, I got the message like: Traceback (most recent call last): File "", line 1, in -toplevel- sys.ps2 AttributeError: 'module' object has no attribute 'ps2' why does it happen? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Iterating over nested lists part2
On 7/2/05, Kent Johnson <[EMAIL PROTECTED]> wrote: Luis N wrote:> def listItems():> l= []> d = {}> for r in range(len(vw)):> for x in range(lt):> ed = desc[x]> exec("d['%s']=vw[%d].%s" % (ed,r,ed)) > l.append(d)> print lIf I understand correctly, you want to take all the rows of the view and turn them into dicts, and build a list of all the dicts. If so, the code above is way too complex.First, you can iterate over a list such as vw directly, you don't have to iterate the indices. Instead offor r in range(len(vw)): do something with vw[r]you just say for vwitem in vw: do something with vwNext, instead of exec you should use getattr(). To put the value into d you don't need either; you can assign to d[ed] directly. To get the 'ed' attribute from vwitem, use getattr(vwitem, ed).I also moved the assignment to d inside the loop so you start each row with a fresh dictionary. Here is the result:def listItems():l= []for vwitem in vw: d = {}for ed in desc:d[ed] = getattr(vwitem, ed)l.append(d)print lKent That's beautiful. I'm really grokking getattr, and I notice that it has some close relations in the family of built-in functions. Luis N. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] search through a list
> import os > > #get a list of Logs in logs folder > LogFiles = os.listdir('/home/nephish/Projects/Piv_GCI/logs') > > #open the loglist file and read the lines > LogList = open('home/nephish/Projects/Piv/logs/LogList.txt', 'r') > LogsRead = LogList.readlines() > > #see if there is a new log file. > for i in LogFiles: > if LogFiles[i] not in LogList: > #if there is a new log, open it and read the lines > StrName=(LogFiles[i]) > NewLog = > open('/home/nephish/Projects/Piv_CGI/logs'+StrName,'r') > NewLogRead=NewLog.readlines() > #print the lines (testing only) > for x in NewLogRead: > print x > print '\n' > print '\n' #end for loop > else: #if the log file is not new, Hi, nephish. I've read Brian's letter. He has given a solution for this problem. And below is another solution for it. StrLog = " ".join([LogsRead[LogsRead.index(line)+1].strip() for line in LogsRead if line.strip() == i]) And I think 'LogFiles[i]' should be replaced by 'i', for 'i' is not an index but a string. Light ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] search through a list
nephish wrote: > LogList = open('home/nephish/Projects/Piv/logs/LogList.txt', 'r') > LogsRead = LogList.readlines() > > #see if there is a new log file. > for i in LogFiles: > if LogFiles[i] not in LogList: Don't you mean "if LogFiles[i] not in LogsRead" ? - Sandip -- Sandip Bhattacharya *Puroga Technologies * [EMAIL PROTECTED] Work: http://www.puroga.com * Home/Blog: http://www.sandipb.net/blog PGP/GPG Signature: 51A4 6C57 4BC6 8C82 6A65 AE78 B1A1 2280 A129 0FF3 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a question
Xinyue Ye wrote: > when I type sys.ps2 after import sys, > I got the message like: > Traceback (most recent call last): > File "", line 1, in -toplevel- > sys.ps2 > AttributeError: 'module' object has no attribute 'ps2' > why does it happen? >From the docs: ps1 ps2 Strings specifying the primary and secondary prompt of the interpreter. These are only defined if the interpreter is in interactive mode. When you are running in IDLE, the command shell is provided by IDLE, not Python, so ps1 and ps2 are not defined. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a question
It works Ok for me, can you cut and paste the full session so we can see exactly what is happening. Also, what environment are you running it in? Windows/Linux/MacOS? IDLE, Pythonwin, Pycrust? All of that might be relevant. Alan G. - Original Message - From: "Xinyue Ye" <[EMAIL PROTECTED]> To: Sent: Sunday, July 03, 2005 8:10 AM Subject: [Tutor] a question when I type sys.ps2 after import sys, I got the message like: Traceback (most recent call last): File "", line 1, in -toplevel- sys.ps2 AttributeError: 'module' object has no attribute 'ps2' why does it happen? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to get 4 numbers from the user in one line for easycomparision?
> I Just need to figure out how to get 4 numbers from > the player on one line for easy comparison, Unless there is a set of batteries somewhere that I don't know about I think you have to rely on reading the line as a string and then splitting it. line = raw_input('Type 4 numbers separated by spaces: ') numbers = [int(n) for n in line.split(' ')] HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] search through a list
Hey there thanks, quote: /try num_of_lines = line_find(LogsRead, "PV050614.LOG") I am binding num_of_lines to the return value. In an interactive session, without the binding, a non-None return value will display on screen. But both interactively and in a program binding it makes it easier to use later. Indeed, in a program, no binding -> no later use. /this is what worked out for me. i am trying to get as familliar as i can in idle because it lets me know as-it-happens when i have something messed up. this put my pieces together. thanks again shawn <>< ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython shaped window
To totally not answer your question, check out - pythoncard.sourceforge.net It's the Visual Basic Userform IDE of wxPython. :) On 7/1/05, Adam Bark <[EMAIL PROTECTED]> wrote: On 6/26/05, Adam Cripps < [EMAIL PROTECTED]> wrote: On 6/25/05, Adam Bark <[EMAIL PROTECTED]> wrote:> Thanks for the info Adam I just seem to be having a problem with the panel > size it greys out nearly all the image. Ideally I would like to make the > panel transparent but I can't work out how to do that.>>> On 6/25/05, Adam Cripps < [EMAIL PROTECTED]> wrote:> > On 6/25/05, Adam Bark < [EMAIL PROTECTED] > wrote:> > > Is it possible to put controls into a shaped window in wxPython. I have > > > tried putting a button on the demo and it becomes the exact size and > shape> > > of the window. Also when I tried to bind it to an action it wouldn't> even> > > start.> > >> > > Adam> > >> >> > I'm working through something similar myself at the moment. > >> > Try adding a wx.Panel to the frame and then the button to the panel.> > You can position them through pos parameter, but it should default to> > the top left of the panel and have a good size if you use > > button.SetSize(button.GetBestSize())> >> > HTH> >> > AdamAdam - how much code do you have? Why not post it either here or thewxpython-users list (to which I'm also subscribed) and we can take a look.Adam--http://www.monkeez.orgPGP key: 0x7111B833 I tried posting to the wxpython-users list but I'm not sure it worked nobody replied anyway. Here's my test script: import wx class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, "Shaped Window", style = wx.FRAME_SHAPED | wx.SIMPLE_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP ) self.hasShape = False self.delta = (0,0) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.bkground = wx.Bitmap("/home/adam/bkgrnd.gif", wx.BITMAP_TYPE_GIF) w, h = self.bkground.GetWidth(), self.bkground.GetHeight() self.SetClientSize((w, h)) self.Bind(wx.EVT_WINDOW_CREATE, self.SetWindowShape) panel = Panel(self, w, h) panel.Show() dc = wx.ClientDC(self) dc.DrawBitmap(self.bkground, 0,0, True) def SetWindowShape(self, evt): # Use the bitmap's mask to determine the region r = wx.RegionFromBitmap(self.bkground) self.hasShape = self.SetShape(r) def OnPaint(self, event): dc = wx.PaintDC(self) dc.DrawBitmap(self.bkground, 0,0, True) def OnMouseMove(self, evt): if evt.Dragging() and evt.LeftIsDown(): x, y = self.ClientToScreen(evt.GetPosition()) fp = (x - self.delta[0], y - self.delta[1]) self.Move(fp) class Panel(wx.Panel): def __init__(self, parent, width, height): wx.Panel.__init__(self, parent, -1, size=(width, height)) button = wx.Button(self, -1, "hello") button.SetSize(button.GetBestSize()) self.SetSize((width, height)) #print dir(self) if __name__ == "__main__": app = wx.PySimpleApp() frame = Frame() frame.Show() app.MainLoop() Thanks. Adam. ___Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor-- 'There is only one basic human right, and that is to do as you damn well please.And with it comes the only basic human duty, to take the consequences.' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT self-implementation?
> > (*)One of the hardest malicious bugs I've seen was by a disgruntled > > employee who deliberately inserted a bug into the C source of the > > companies compiler. He then recompiled the compiler (using the working > > compiler) to produce a faulty compiler. He then removed his bugs in > > the source code so it was back to the correct version. He then > > recompiled the good source with the faulty compiler to produce a new > > faulty compiler. He then left the company... > > > > It took a long time to figure out what was wrong and why... > > good lord, but if that fellow could only have harnessed that > ingeniousness for the forces of good! Hi Brian, You may find the following paper by Ken Thompson an interesting one on this topic: "Reflections on Trusting Trust": http://www.acm.org/classics/sep95/ It follows the exact stuation that Alan mentioned. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT self-implementation?
> > Now's not the time in my life to start a comp. sci. degree. So, my > > questions are: > > > > 1) What would be good terms to google for to find an explanation of > > how the seeming magic doesn't violate all reason? Hi Michael, The idea is that we can use _ourselves_ as the initial compiler for a simplified version of the language that we're trying to compile. We know, for example, that something like: ## print "hello world" ## should produce something machine-like, like: 1. Put the bytes "hello world" somewhere where the system can see things. 2. Invoke whatever the underlying system provides us to print those bytes. and if we knew what the hardware looked like, we could write out the exact low-level instructions that produces the words "hello world" on screen. Just as a sample of what these lower-level instructions might look like, here's a sample using Python's bytecode disassembler: ## >>> import dis >>> def say_hello(): ... print "hello world" ... >>> dis.dis(say_hello) 2 0 LOAD_CONST 1 ('hello world') 3 PRINT_ITEM 4 PRINT_NEWLINE 5 LOAD_CONST 0 (None) 8 RETURN_VALUE ## It's a lot more lines for doing something simple, but that's exactly why we write programs in higher-level languages now. Anyway, if we know what the underlying low-level language looks like we can take something written in a higher level language, and manually transcribe those high-level constructs into the lower-level language. So the base case is ourselves and the hardware. *grin* This is usually very tedious work, though, so many metacircular implementations will use a limited subset of the language, one that is really easy to translate down to primitive actions. That's what the PyPy folks are doing: they're writing Python in Python, with the caveat that the kind of Python that they're writing is a "restricted" one that uses less features than full-on Python: http://codespeak.net/svn/pypy/dist/pypy/documentation/coding-guide.txt They're doing this to make the translation to the lower machine language easier: I think their plan is to take their PyPy interpreter, and mechanically translate it down into C. This implies that they're planning to use tools to do the translation, but in a pinch, they could always use themselves and do the translation by hand. Such a process would be very bug prone and painful, but it's possible. *grin* > > 2) Much harder, so please pass unless you've a link you know of > > off-hand: any recommendations of particular things that I could read? The classic textbook "Structure and Interpretation of Computer Programs" might interest you: http://mitpress.mit.edu/sicp/ Chapter 4 goes into writing a Scheme interpreter in Scheme, and the chapter right after that talks about how to take that interpreter and mechanically rewrite it into low-level instructions. Best of wishes! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How do I make Python calculate square roots?
On Sat, 2 Jul 2005, Reed L. O'Brien wrote: > > Does anyone know how to make Python calculate square roots? > > > Raise to the 1/2 power. > > >>> 4**.5 > 2.0 > >>> 16**.5 > 4.0 > >>> 81**.5 > 9.0 By the way, if you need to take the square roots of negative numbers, then the 'sqrt' function in the cmath module should do the trick: ## >>> (-1)**0.5 Traceback (most recent call last): File "", line 1, in ? ValueError: negative number cannot be raised to a fractional power >>> >>> import cmath >>> cmath.sqrt(-1) 1j ## Best of wishes! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT self-implementation?
> You may find the following paper by Ken Thompson an interesting one on > this topic: "Reflections on Trusting Trust": > > http://www.acm.org/classics/sep95/ > > It follows the exact stuation that Alan mentioned. Yes, I hadn't seen the Thompson paper before but I notice it was dated 1989 and the guy I'm discussing left in 1991. I know he read the ACM papers so now I guess I know where he got the idea! Mind you even though I know how he did it I'm still not sure I could replicate the feat even now! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Sudoku puzzle implementation
Hi all, If you aren't aware of Sudoku, this is it - http://www.sudoku.com/ Big craze at my office, and I've just been wracking my brains to try and think of how to model it in Python (in order to solve.) What I'm not sure of is how to implement it. Basic rundown of a Sudoku puzzle is - Generally composed of 9 x 9 squares, with the box divided further into nine 3 x 3 mini-squares. Certain numbers are given at the start. Sudoku puzzles follow these rules - Each column, row and mini-square must contain the complete set of numbers 1 - 9. The numbers do not have to be sequential. Each column, row, and mini-square can only contain each number once So that's it. So, to implement... I was thinking, a list of lists of lists [grid[0], grid[1], grid[2], grid[3], grid[4], grid[5], grid[6], grid[7], grid[8] ] [ [ [a,b,c], [d,e,f,], [g,h,i] ], [ [j,k,l], [m,n,o], [p,q,r] So forth. This approach gets a little confusing in terms of array arithmetic but it's livable. Now each variable can be [1-9] Variable a (grid[0][0][0]) can be 1 unless grid - any member of grid[0] is 1 row - any member of grid[1][0] or grid[2][0] is 1 column - grid[3][x][0] or grid[6][x][0] is 1 (where x is an index of 0 to 2) My current approach is to start with each variable as a list of numbers [1-9] and to pop numbers based on the above rules, but I got thinking about sets and what not, and wondered if they would work better, unions and intersections and whatnot. Problem is, I don't know the first thing about set mathematics. Any pointers in the right direction would be gratefully appreciated. Regards, Liam Clarke-- 'There is only one basic human right, and that is to do as you damn well please.And with it comes the only basic human duty, to take the consequences.' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] search through a list
Hey there, sorry to bother you again about this same problem but i have a line of code in this same issue that works in idle but it does not work in a regular script. that same thing i am trying to do, reading the directory, comparing the list of files to a list . just want to catch the newest lines of a log file to process later. here is what i have ( kinda long ) #!/usr/bin/python # Update Database import os print ' ' print ' ' #get a list of log files in the directory LogsInDir=os.listdir('/home/nephish/Projects/Piv_CGI/logs') print LogsInDir #testing only, remove later #read the contents of the log list LogList = open('/home/nephish/Projects/Piv_CGI/LogList.txt', 'r') LogsRead=LogList.readlines() LogList.close() print 'Lines of LogList.txt' for i in LogsRead: print i #testing only, remove later #this function returns the number of lines on record for each log file. def line_finder(LogsInDir, flag): flag=flag.strip() return_next=False for line in LogsInDir: if return_next: return line.strip() else: if line.strip() == flag: return_next = True NumLogsInDir = len(LogsInDir) NextLog = 0 while NextLog < NumLogsInDir: print 'opening file '+LogsInDir[NextLog] print ' ' Count_in_Log = open('/home/nephish/Projects/Piv_CGI/logs/'+LogsInDir[NextLog], "r") Defer = Count_in_Log.readlines() Count_in_Log.close() CountEmUp = len(Defer) print 'number is ' print CountEmUp NumLinesOnFile=line_finder(LogsRead, LogsInDir[NextLog]) print NumLinesOnFile if CountEmUp > int(NumLinesOnFile): print " "+LogsInDir[NextLog]+" is longer than on record" XtraLines = int(NumLinesOnFile) - CountEmUp print XtraLines else: print ' '+LogsInDir[NextLog]+" is not greater than on record" XtraLines=0 print XtraLines NextLog=NextLog+1 print 'done' __ the line in question is this one: NumLinesOnFile=line_finder(LogsRead, LogsInDir[NextLog]) print NumLinesOnFile if i run this in idle printing NumLinesOnFile gives me a string 14 when run in a terminal it returns "None" dont get it. is it because it is in a while loop? any ideas would be awesome here. thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Sudoku puzzle implementation
Liam, I couldn't get "into" your approach at the moment, but I was wondering if you have looked at the following: First, the Reverse Puzzle section of: http://cs.gettysburg.edu/~tneller/resources/ai-search/uninformed-java/ and secondly more generally: http://www.gamedev.net/reference/articles/article1374.asp http://www.gamedev.net/reference/articles/article1433.asp http://www.gamedev.net/reference/articles/article2041.asp Just some references I've used for puzzle problems, Lee C Liam Clarke wrote: > Hi all, > > If you aren't aware of Sudoku, this is it - http://www.sudoku.com/ > > Big craze at my office, and I've just been wracking my brains to try and > think of how to model it in Python (in order to solve.) > > What I'm not sure of is how to implement it. > > Basic rundown of a Sudoku puzzle is - > > > Generally composed of 9 x 9 squares, with the box divided further into > nine 3 x 3 mini-squares. Certain numbers are given at the start. > > Sudoku puzzles follow these rules - > > Each column, row and mini-square must contain the complete set of > numbers 1 - 9. > The numbers do not have to be sequential. > Each column, row, and mini-square can only contain each number once > > So that's it. So, to implement... > > I was thinking, a list of lists of lists > [grid[0], grid[1], grid[2], > grid[3], grid[4], grid[5], > grid[6], grid[7], grid[8] ] > > [ > [ > [a,b,c], > [d,e,f,], > [g,h,i] > ], > [ > [j,k,l], > [m,n,o], > [p,q,r] > > So forth. This approach gets a little confusing in terms of array > arithmetic but it's livable. > > Now each variable can be [1-9] > > Variable a (grid[0][0][0]) can be 1 unless > > grid - any member of grid[0] is 1 > row - any member of grid[1][0] or grid[2][0] is 1 > column - grid[3][x][0] or grid[6][x][0] is 1 (where x is an index of 0 to 2) > > My current approach is to start with each variable as a list of numbers > [1-9] and to pop numbers based on the above rules, > but I got thinking about sets and what not, and wondered if they would > work better, unions and intersections and whatnot. > > Problem is, I don't know the first thing about set mathematics. > > Any pointers in the right direction would be gratefully appreciated. > > Regards, > > > Liam Clarke > -- > 'There is only one basic human right, and that is to do as you damn well > please. > And with it comes the only basic human duty, to take the consequences.' > > > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Confused about error message
I'm new to Python and computer programming in general. Eventually I got sick of just reading my programming books and typing code from them into the interpreter, so I decided to write a script that will grab files from websites and save them to the hard drive, and if they're compressed, unzip them. Here is my code: #! /usr/bin/python # 07/03/2005 # file_downloader.py - Downloads files and unzips them if they are a .zip file from urllib import FancyURLopener import os.path import zlib import fnmatch def get_file(address, filename, url): try: file_content = FancyURLopener() file_content.retrieve(address, filename) print "Finished downloading %s from %s." % (filename, url) except(), error: print "An error has occured:", error 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 Although sometimes it takes me awhile, I can usually spot the errors that I've made when they come up. I've stared at this one for two days and I still don't see the syntax error the interpreter is referring to. What am I doing wrong? I'm using Python 2.3 on Mac OS X version 10.3.9, and I run my scripts from Terminal. Thank you for your consideration, Gelsey ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about error message
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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor