Perl started with scripting, so many design philosophy are centered around scripting. Python, I think, is started with the goal of building applications. My first impression when I learned Python (around 2000) was the OOP nature of Python. Building classes and objects were least in my mind when scripting.
A few examples:
Perl (flexible/optional function call interface)
print "hello world\n";
Python (the insistence of function call parenthesis)
print("hello world")
Perl (direct string substitution thanks to sigils)
print "Hello $name\n";
Python (a few formats, keep searching for the perfect ones)
print("Hello %s\n" % name);
Perl (a core set of shell like patterns)
if (!-d $dir) {
mkdir $dir;
}
chdir $dir;
foreach my $f (glob("*.txt")) {
...
}
Python
import os
import glob
# google for usages
Perl (good lexical scopes)
if ($do_A) {
my $x = "A";
work_with($x);
} else {
my $x = "B";
work_with($b);
}
Python
if do_A:
x = "something" # did I changed x for somewhere else?
...
Perl (a set of defaults balacing the succinctness and readability)
my %opts;
while (<In>) {
if (/(\w+):\s*(.+)/) {
$opts{$1} = $2;
}
}
Python
import ...
...
m = re.match(r'...', line, re_flags)
if m:
opts[m.group(1)] = m.group(2)
Perl's philosophy is "There is more than one way to do it", pick the way that makes most sense to you.
Python's philosophy is "There should be one-- and preferably only one --obvious way to do it", but obviousness is subjective to some, and for the rest, you need learn/search/train the "one" way.
A few examples:
Perl (flexible/optional function call interface)
Python (the insistence of function call parenthesis) Perl (direct string substitution thanks to sigils) Python (a few formats, keep searching for the perfect ones) Perl (a core set of shell like patterns) Python Perl (good lexical scopes) Python Perl (a set of defaults balacing the succinctness and readability) Python Perl's philosophy is "There is more than one way to do it", pick the way that makes most sense to you.Python's philosophy is "There should be one-- and preferably only one --obvious way to do it", but obviousness is subjective to some, and for the rest, you need learn/search/train the "one" way.