Why did Quora choose Python for its development?

Chris Angelico rosuav at gmail.com
Tue May 24 19:38:08 EDT 2011


On Wed, May 25, 2011 at 9:16 AM, John Bokma <john at castleamber.com> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>
>> Yes, I believe that was Perl. And an amusing quote. But most of the
>> point of it comes from the fact that Perl uses punctuation for most of
>> its keywords,
>
> For example?
>
>> whereas (say) Python uses English words; it's a lot more
>> fun to crunch something down when you can use $|
>
> That's not a keyword but a special (global) variable. On top of that,
> you don't have to use it [1] and most people most likely encounter this in
> (badly) written CGI scripts originating in the last century.

Okay, poor example. But there's a lot of Perl that uses concise
notation for things that in Python are keyworded; for instance,
regular expressions. I'm insufficiently fluent in Perl to quote good
examples; mainly what I'm referring to is the notion of operators that
are separators, as opposed to keywords that get blank-delimited. I
generally prefer syntactic elements to be punctuation (eg { } rather
than BEGIN and END (or DO and END)). It does also make things easier
to crunch, for better or for worse.

>> and friends than when you have to put "x and y", complete with spaces,
>> for a simple boolean.
>
> Perl has also the and logical operator. This is legal Perl:
>
> if ( $x and $y ) {
>  print "yes\n";
> }

That's at a completely different precedence level, isn't it? For
operators up where you expect them to be, there's && and ||. A bit of
digging (why isn't this sort of thing always the first hit for "<name
of language> operator precedence" in Google?) brought up:

http://perldoc.perl.org/perlop.html

For instance:

$a = $b && $c ? $e : $f;
# versus
$a = $b and $c ? $e : $f;

The first one is an assignment to $a, conditional on two variables.
The second is an unconditional assignment to $a, and then based on
that, evaluates either $e or $f and does nothing with it.

Python:
a = e if b and c else f

It's pretty similar, actually (although, coming from a C background, I
do prefer to have the condition first); but I could crunch the first
one down a lot, while the last one is almost as tight as it can be.

$a=$b&&$c?$e:$f;
a=e if b and c else f

It's that crunched appearance that makes Perl look like line noise,
and the open keyworded appearance that makes Python look like
pseudocode. But that's not necessarily a good thing; a courteous
programmer can space out Perl to keep it readable, and he then has the
option of crunching pieces that are 'logically one' and spacing out
the parts that aren't:

$a= $b&&$c ? $e : $f;

Silly, contrived example, but in production code I've often had
situations where it makes sense to space out one part of an expression
and crunch another. And when everything's an English word, that's not
an available option.

Oh, and that's ignoring the issue that not everyone is fluent in English.

That said, though, I do find Python a lot easier for reading other
people's code in. A LOT easier.

Chris Angelico



More information about the Python-list mailing list