Why should I switch to Python?

James Felix Black usenet at inter-slice.com
Thu May 11 01:09:07 EDT 2000


> Two big ones come to mind: using complex data structures, and
> modularizing your code. Both are much easier in python.

I won't dispute your second point, but I don't understand your first.

[ code snipped ]

> In perl, doing this is so painful to me that I'm not even going to
> try it now, and it only gets worse as your data structures get more
> complicated.

I'm not sure exactly what you mean:

%friends = { Bob => [ ], Jane => [ "Lisa", "Mabel", "Freddy" ],
             Lisa => [ "Mabel" ] };

for $name (keys %friends) {
  print "$name has these friends:\n";
  for $f (@{ $friends{ $name } }) {
    print " ", $f;
  }
  print "\n";
}

Sure looks similar, doesn't it?  Of course, the de-referencing of the 
array reference looks bizarre, and perl doesn't have the wonderful REPL 
loop, but the assignment is almost completely identical to the python 
syntax.

What I (as a perl programmer/python novice) really miss in python are 
true closures.  Is this a language feature yet?  One marvelous thing 
that python has, though, is reduce, which I find so massively useful 
that I carry it around with me in perl land wherever I go.

YMMV, of course,
(jfb)



More information about the Python-list mailing list