Searching for the best scripting language,

L

Lothar Scholz

And it was corrected to reflect that the Ruby site is "down for
maintenance".

Maybe they need to use Zope? :)

And it's /. :)

No this posting is as wrong as yours.

The site is down since 29. May 2004 and all data will be manually
reviewed before the services go back online. The RAA is back since
7.Juni 2004, the other services will follow.
 
R

Richard James

Peter Hansen said:
Ryan said:
The proof is in the source. This is part of a ruby program I wrote. This
snippet is actually a single 'line'. I broke it into several lines for
slightly improved readability. This single line would probably take at
least 15 lines to do in python, probably more if you wanted to do it
intelligently.

["*.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}`} }

This is proof of something, I'm sure, but for me it's simply another
indication that (a) Ruby is more like Perl than it is like Python,
(b) unreadable code can be written in any language, and (c) I
really don't mind using 15 lines to write something if it means
the resulting code can readily be understood.

Thanks for reinforcing my lack of interest in switching to Ruby. :)

-Peter

Well back in my day, in '75, "Real men" programmed in Intel binary
machine codes without using those "sissy" Assembly language
mnemonics...

I think the value of maintainable code far outweighs cute one line
coding tricks...

And no matter how close to the hardware it made you feel, I really
don't miss those #%$@ front panel switches! :)

-- R.J.
 
P

Peter Hansen

Richard said:
Well back in my day, in '75, "Real men" programmed in Intel binary
machine codes without using those "sissy" Assembly language
mnemonics...

You used *binary*?! Ah, luxury....
 
R

Roy Smith

Peter Hansen said:
You used *binary*?! Ah, luxury....

Yeah, right. When I started out, they only let us use zeros. You had
to pay your dues for a few years before they started letting you use any
ones.
 
C

Carl Banks

Ryan said:
The proof is in the source. This is part of a ruby program I wrote. This
snippet is actually a single 'line'. I broke it into several lines for
slightly improved readability. This single line would probably take at
least 15 lines to do in python, probably more if you wanted to do it
intelligently.

["*.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,
 
S

Steve Lamb

Ryan said:
["*.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.
 
C

Carl Banks

Steve said:
Ryan said:
["*.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.

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).
 
S

Steve Lamb

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)))

Ah, grab anything with a rar extension and more (badly split usenet
binaries?) and splice them together.
I don't know what sesc is. I assume he had defined it elsewhere,

Stab in the darb based on the cat call as well as the purpose of this
snippet I would surmise "space escape". IE, escape possible spaces in the
file name so as not to flub the command line that hits the system call.
 
P

Peter Hansen

Carl said:
Heh. It seems to me that, by the same reasoning, we could claim that
Python has verbose execution. Someone's obviously willing to give
Perl the benefit of the doubt here, but not Python. I smell
shenanigans.

I tried a few Google searches, even apparently reaching the page that
started this thread, but I can't see what "verbose execution" might
mean other than (a guess) a "trace" mode which prints something for
every line executed as the interpreter runs. And, if that's really
what it is, then Python does have the capability pretty easily, via
sys.settrace(). (Which I'm sure Carl knows, therefore I assume my
guess is wrong.)

-Peter
 
C

Cameron Laird

I tried a few Google searches, even apparently reaching the page that
started this thread, but I can't see what "verbose execution" might
mean other than (a guess) a "trace" mode which prints something for
every line executed as the interpreter runs. And, if that's really
what it is, then Python does have the capability pretty easily, via
sys.settrace(). (Which I'm sure Carl knows, therefore I assume my
guess is wrong.)
.
.
.
I idly and gratuitously submit that I regard it as more likely
the Scriptometer folks are that ... naive.
 
D

David Eppstein

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).[/QUOTE]

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...
 
H

Hung Jung Lu

Well back in my day, in '75, "Real men" programmed in Intel binary
machine codes without using those "sissy" Assembly language
mnemonics...

Nahh... I had a friend who not only did program straight in
hexadecimal machine code, calculated all the offsets on the fly
without any pencil/paper/calculator, more over, very often, when we
had bugs with a UV-EPROM, he would tell us: "guys, no need to change
the program, see, I can just re-wire the circuit here, put a gate
here, flip these and those switches, and done." When you can
re-program by doing it with hardware, that's "real man". It was
perhaps "sissy" to him to re-write programs and re-record the EPROM,
when he could do it straight by hardware changes in a shorter amount
of time.

(Back then, he never forgot a single telephone number, even if he
heard it only once. Some people are just born hardware geniuses.)

regards,

Hung Jung
 
C

Carl Banks

Peter said:
I tried a few Google searches, even apparently reaching the page that
started this thread, but I can't see what "verbose execution" might
mean other than (a guess) a "trace" mode which prints something for
every line executed as the interpreter runs. And, if that's really
what it is, then Python does have the capability pretty easily, via
sys.settrace(). (Which I'm sure Carl knows, therefore I assume my
guess is wrong.)


I took it to mean the same thing you did (you might note that shell
scripts are listed as having verbose execution, which pretty much can
only mean that one thing).

My point was, Perl's interactive interpretter isn't "real"; to get it,
you have to invoke the debugger, or use a little Perl program to get
the effect. Likewise, Python's verbose execution isn't "real"; you
can't get it with a simple command line argument. You have to define
a settrace function.

Yet, they list Perl as having an interactive interpretter, by Python
as not having verbose execution. Smells like a someone has an
unconscious bias here.
 
D

David Eppstein

Carl Banks said:
I took it to mean the same thing you did (you might note that shell
scripts are listed as having verbose execution, which pretty much can
only mean that one thing).

My point was, Perl's interactive interpretter isn't "real"; to get it,
you have to invoke the debugger, or use a little Perl program to get
the effect. Likewise, Python's verbose execution isn't "real"; you
can't get it with a simple command line argument. You have to define
a settrace function.

Yet, they list Perl as having an interactive interpretter, by Python
as not having verbose execution. Smells like a someone has an
unconscious bias here.

The command lines they used for getting an interactive interpreter are
listed near the bottom of the page
http://merd.sourceforge.net/pixel/language-study/scripting-language/
for perl, the line is
perl -de 1
and the verbose execution command is
perl -d:Trace
If you know of a batteries-included and similarly easy way to get
verbose execution of some sort for Python, I suggest you send it to them
via the email link at the top of the page -- I've found them open to
feedback and suggestions.

BTW, the shell script verbose execution is "sh -x".
 
R

Reinhold Birkenfeld

Richard said:
Let the rabid "in defense of Python" flames begin!

Come on, folks. Just look what "language" got the most points.
Who would not refuse to write a shellscript of more than, say, 100 lines
(except for quoting masochists)?

Reinhold
 
C

Carl Banks

David Eppstein said:
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...[/QUOTE]

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.
 
D

David Eppstein

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.

I was wondering where the import re was supposed to be used...
so the line
f.update(glob.glob(prefix+pattern))
should become
for listing in glob.glob(prefix+pattern):
f.add(re.sub(r"\.\d+[\d.-]*$","",listing)
I guess? Not so different from what you posted, after that change...

As long as we're admitting to mistakes in code, I should have used
sets.Set instead of just Set in the second line.
 
T

Thorsten Kampe

* Ryan Paul (2004-06-14 02:20 +0100)
I recently learned ruby, merely out of curiosity. Now that I know it, I
dont write ANY shell utilities with python anymore. Ruby is a much better
choice for almost all simple administrative tasks. For larger programs,
there are times when python seems like a better choice. Python enforces
consistency and readability. In an environment where many people will be
working on the same code for an extended period of time, the benefits of
python become apparent. That isnt to say that ruby *cant* be used in
situations like that. If ruby programmers layout strict guidelines for a
project regarding style and methodology, it would be just as effective.

The proof is in the source. This is part of a ruby program I wrote. This
snippet is actually a single 'line'. I broke it into several lines for
slightly improved readability. This single line would probably take at
least 15 lines to do in python, probably more if you wanted to do it
intelligently.

["*.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}`} }

If you still believe in oneliners you deserve Ruby (and Perl). I
wouldn't want to be you if you ever have to modify your code some time
in the future.

Thorsten
 
C

Christian Tismer

Max said:
Everyone knows that any scripting language shootout that doesn't show
Python as the best language is faulty by design.

loveley :)

--
Christian Tismer :^) <mailto:[email protected]>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top