Thanks for Python...

Mordy Ovits movits at lockstar.com
Thu Jun 24 16:55:38 CEST 1999


William Tanksley wrote:
> Sure, but we've got Pilots, so that's not an open option.  Fortunately,
> the Pilot has Quartus Forth available for it -- it's not Python, but
> honestly, Forth fits the limitations of the device better.

I had a Pilot for a year before I realized that it wasn;t what I needed.  It's a
glorified organizer, when what I wanted was a pocket computer.  So I shelled out
for the E-100 and I've never looked back.  The difference is light years, not
miles.
 
> I used Quartus on my Crypto exam to solve a modular equation after I
> forgot how to solve modular equations (I had it use brute force).

Wow!  I wish I had had my E100 when I was in college.  I just realized how
awesome that would have been. :-)
 
> I'd still like to have Python, but dang, Quartus is good at what it does.
> Python and Forth -- for two different reasons, pretty much my favorite
> languages.

Best tool for the job wins.  Agreed.
 
> >o Mordy Ovits
> >o Cryptographic Engineer
> >o LockStar Inc.
> 
> >#!/usr/local/bin/python
> >from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!=
> >'-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d
> >while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce(
> >lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1)))
> 
> You know, the first time I saw this it was in ESR's .sig, and I tried to
> remember how long the Perl version had been.  A few minutes of searching
> revealed that it was three lines long -- but also revealed that it was
> using bc rather than Perl to do most of the work!  I spent about half an
> hour searching for the real Perl version, only to find that it was five
> lines long.
> 
> The Python for this .sig is shorter than the Perl!  Cool, eh?

The SECOND time I saw that sig was in ESR's mail.  The first was mine.  I doubt
ESR copied mine, but who knows? :-)
Actually there IS a 3 line PERL version, but it does use dc for the heavy
lifting.  I consider that cheating.

Python *is* my favorite language,
Mordy


-- 
o Mordy Ovits
o Cryptographic Engineer
o LockStar Inc.
---------------------------------------------------------------------------
#!/usr/local/bin/python 
from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!=
'-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d
while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce(
lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1)))




More information about the Python-list mailing list