[Tutor] Files, directories and syntax

Sean 'Shaleh' Perry shaleh@valinux.com
Thu, 01 Mar 2001 12:52:26 -0800 (PST)


On 01-Mar-2001 Karen Windus wrote:
> I've been asked to resend this as an attachment. Actually, I'll just repaste 
> into this document and hope that works. I was sending the last message from 
> my shell account so I guess pine didn't like my attempts to indent (the 
> script is indented, although I don't know if it is correctly).
> 

if what I see matches your code, no it is not.  I played with it some, and you
have other issues as well.


>#! /usr/bin/env python
> 
> def change_lines(directory = None):
>    import glob, re
>    result = []
>    filepattern = '*.{html}'
>    filelist = glob.glob1(directory, filepattern)
>    regexp = re.compile(r"Your Turn")
>    for i in filelist:
>    file = open(i,"rw")
>    print "We opened a file"
>       for file in filelist:

but you just opened 'file' as a file object and now you are using
it as an entry from list (again).  You have two 'for foo in filelist' loops
here.  You really need to read this line by line an make sure you have what you
want.  Feel free to mail me personally and we can solve your issues once you
think the logic out a little more.