Why should I switch to Python?

andres at corrada.com andres at corrada.com
Thu May 11 09:16:21 EDT 2000


On Thu, May 11, 2000 at 12:09:07AM -0500, James Felix Black wrote:
> > 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.
>
> 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.
>
 
C'mon, let's be reasonable about this. Only die-hard Perl programmers can
love the syntax of that language when it comes to complicated data
structures. I quote from "Programming Perl", pg 243, emphasis mine:
 
   "For both practical and philosophical reasons, Perl has ALWAYS been biased
    in favor of flat, linear data structures."
 
One of the main reasons I came to Python was that I got tired of coding
complex data structures in Perl and getting them wrong. Unless you are
constantly creating these structures, you forget Perl's convoluted syntax.
This failing of Perl is well attested by the fact that "Programming Perl"
has to include a section of "Data Structure Code Examples" to explain how to
create and use anything other than a one-dimensional list or hash. Heck,
a brief tutorial in the book even includes a section on "Common Mistakes".

Andres Corrada




More information about the Python-list mailing list