Thanks for Python...

John Klassa klassa at aur.alcatel.com
Thu Jun 24 10:35:12 EDT 1999


On Wed, 23 Jun 1999 20:24:59 GMT, wtanksle at dolphin.openprojects.net wrote:
  > >#!/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?

It doesn't run for me...  What's it supposed to do?  When I run it, I get:

Traceback (innermost last):
  File "/tmp/foo", line 2, in ?
    from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda
x:x[:1]!=
ValueError: unpack list of wrong size

-- 
John Klassa / Alcatel USA / Raleigh, NC, USA




More information about the Python-list mailing list