Searching for the best scripting language,

Carl Banks imbosol at aerojockey.com
Tue Jun 15 18:27:31 CEST 2004


David Eppstein <eppstein at ics.uci.edu> wrote in message news:<eppstein-C44C69.17103814062004 at news.service.uci.edu>...
> 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...

I just noticed that I mistakenly left out the regexp in my clean code.
 Where I had f[listing] = None, I should have
f[re.sub(r"\.\d+[\d.-]*$","",listing)] = None, or an extra varible.


-- 
CARL BANKS



More information about the Python-list mailing list