List comparison help please
Bucco
phinsxiii at gmail.com
Sun Aug 20 19:55:43 EDT 2006
Simon Forman wrote:
> 1) Don't use "dir", "file", and "list" as variable names, those are
> already python built in objects (the dir() function, list type, and
> file type, respectively.)
Thanks. My own stupidity on this one.
> 2) 'r' is the default for open(), omit it. "self.flist =
> open(file).readlines()"
>
Could you clarify? Show an example. Sorry if I sound newbyish, but I
am.
> 5) Since you have a list of things you're matching (excluding actually)
> this part:
>
> > for item in self.flist:
> > if item == fname[:-4]:
> > pass
> > else:
> > self.matches.append(fname)
>
> could become:
>
> if fname[:-4] not in self.flist: self.matches.append(fname)
Thanks. This was what I was looking for.
> 6) Why are you using #~ for comments?
This is just the automatic commenting on scite. I put my cursor on the
line I want to comment and press ctrl-q ans scite comments out the
whole line or selection. As for why the lines are commented; I
commented these lines so I could test out some of the code prior to
running the next bit.
> Also, check out os.path.splitext()
> http://docs.python.org/lib/module-os.path.html#l2h-1761
>
I will check this out also.
Thank You for your help. You have answered some questions for me.
Thanks:)
SA
More information about the Python-list
mailing list