which feature of python do you like most?
jeff at schwabcenter.com
Tue Nov 8 18:56:26 CET 2005
zelzel.zsu at gmail.com wrote:
> which feature of python do you like most?
> I've heard from people that python is very useful.
> Many people switch from perl to python because they like it more.
> I am quite familiar with perl, I've don't lots of code in perl.
> Now, I was curious and interested in the python people.
> They certainly made their best choice from perl to python.
> but i have no interesting python experence before, thought i've read a
> few chapters
> of a python tutorial book. The things are much like the perl one.
> I have no idea why people are so facinating with python.
> So I post this question: What do you use in your dairy work with
> what is the thing that python makes you happy?
> I certainly don't want to miss a language if it's so great!
> can anyone share your happy experence with python?
I love Perl. I have started using Python more, partially because it's
in vogue, but largely because hastily written code seems to come out
"cleaner." One certainly can write clear, maintainable code in Perl,
but doing so in Python feels a bit more natural. For example:
- Object orientation was a design goal of Python, but had to
be retrofitted onto Perl.
- Every module I write in Perl contains:
use warnings; # Should have been the default.
use strict; # Check for dubious constructs.
# Probably some export code like this:
our @ISA = qw( Exporter );
our @EXPORT_OK = (
# "Real" code.
1 # Return good value on import.
In Python, none of this is necessary.
- Python knows what indentation means, so I get to skip a
lot of curly braces.
For one-liners, I still use Perl, specifically because:
- I don't have to import "os" and "sys" modules just
to basic tasks like issuing system commands.
- Perl will auto-vivify variables with reasonable
default values. E.g., if I ++$count, Perl has
enough intuition to know that I wanted $count
initialized to zero.
- Perl lets me use very clean syntax for subroutine
invocation, e.g. by skipping parentheses and being
aware of (list or scalar) context.
Hope this helps.
More information about the Python-list