Searching for the best scripting language,

Steve Lamb grey at despair.dmiyu.org
Mon Jun 14 18:15:12 EDT 2004


On 2004-06-14, Carl Banks <imbosol at aerojockey.invalid> wrote:
> Ryan Paul wrote:
>> ["*.rar.*", "*.r[0-9][0-9].*"].each {|fn|
>>  Dir[$prefix+fn].collect {|x|
>>  x.gsub(/\.\d+[\d.-]*$/,"")}.uniq.each {|x|
>>  `cat #{sesc x}.* > #{sesc x}`} }

> Oh boy.  I believe this untested Python code does what you want, also
> one line, also wrapped in the name of "clarity."

>     for f in dict([(__import__('re').sub(r"\.\d+[\d.-]*$","",x),None)
>                    for fn in ("*.rar.*","*.r[0-9][0-9].*")
>                    for x in __import__('glob').glob(prefix+fn)]):
>         __import__('os').system("cat %s.* > %s" % (sesc(f),sesc(f)))

> This would take about 7 lines in well-written Python, not 15.

> bad-code-can-be-written-in-any-language-ly yr's,

    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.


-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list