On Dec 4, 10:39 am, Cong Ma <[EMAIL PROTECTED]> wrote:
> Lawrence D'Oliveiro wrote:
> > for \
> > Entry \
> > in \
> > sorted \
> > (
> > f for f in os.listdir(PatchesDir) if PatchDatePat.search(f) !=
> > None
> > ) \
> > :
> > Patch = (open,
> > gzip.GzipFile)[Entry.endswith(".gz")](os.path.join(PatchesDir, Entry), "r")
> > ... read from Patch ...
> > Patch.close()
> > #end for
>
> The "if ... != None" is not necessary... "if PatchDatePat.search(f)" is OK.
> And I don't like it...
Maybe the whole if clause is not necessary? This is how I would try
it:
for Entry in filter(PatchDatePat.search, os.listdir(PatchesDir)) :
fname = os.path(PatchesDir, Entry)
Patch = file(fname) if fname.endswith('.gz') else GzipFile(fname)
# ... read from Patch ...
Patch.close()
--
http://mail.python.org/mailman/listinfo/python-list