Searching for the best scripting language,
David Eppstein
eppstein at ics.uci.edu
Mon Jun 14 20:10:38 EDT 2004
In article <FXpzc.96175$DG4.66965 at fe2.columbus.rr.com>,
Carl Banks <imbosol at aerojockey.invalid> wrote:
> > Ok, see, here's the thing. I look at the Ruby code and can kind
> > of follow it. I look at the Python code and can kind of follow it.
> > but in neither case have I, in glancing here and there today, been
> > able to decipher exactly what is going on. Care to show the 5 line
> > long form to see if I get that? No explination, just curious to see
> > if I can get it reading real code instead of hacked up line noise.
>
> Of course you can.
>
> import glob
> import os
> import re
>
> f = {}
> for pattern in ("*.rar.*","*.r[0-9][0-9].*"):
> for listing in glob.glob(prefix+pattern):
> f[listing] = None
> for filename in f:
> os.system("cat %s.* > %s" % (sesc(filename),sesc(filename)))
>
>
> I don't know what sesc is. I assume he had defined it elsewhere,
> because he said this was only part of a script he wrote (and that's
> what scares me--I can understand a throwaway one-liner looking like
> this, but not a line in a script).
As long as we're cleaning up code, how about
import glob, os, sets
f = Set()
for pattern in ("*.rar.*","*.r[0-9][0-9].*"):
f.update(glob.glob(prefix+pattern))
for filename in f:
os.system("cat %s.* > %s" % (sesc(filename),sesc(filename)))
Now it's not even much longer than the original unreadable mess...
--
David Eppstein http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science
More information about the Python-list
mailing list