Python is readable
rosuav at gmail.com
Thu Mar 15 13:21:29 CET 2012
On Thu, Mar 15, 2012 at 10:59 PM, Kiuhnm
<kiuhnm03.4t.yahoo.it at mail.python.org> wrote:
> On 3/15/2012 12:47, Chris Angelico wrote:
>> It's a little odd, perhaps, if seen in a vacuum. But everything counts
>> from zero - list indices, etc - so it makes sense for range(len(lst))
>> to return indices valid for lst.
> Maybe range uses [...) intervals? So range(a,b) is a,a+1,a+2,...,b-1 and
> range(b) is just short-hand for range(0,b)?
Yup. It's amazing how accurate your conjectures are - it's almost like
you've been reading the docs! :D But yeah, that's pretty logical IMHO;
and having gotten used to [) intervals in many areas of computing,
I've come to find  intervals disconcerting. Bible passages are
described as, for instance, John 14:5-7, which is a three-verse
passage (5, 6, 7), even though 7-5=2.
However, inclusive-inclusive intervals have the benefit that they
don't require the element "beyond the last" to be indexable. This is
important if you're working with something that takes up all of
addressable memory - going back to the IBM PCs on which I learned to
code, you could use one 64KB segment for an array, but then there's no
way for a 16-bit integer to indicate "past the end".
>> List comps are pretty readable if you know how programming languages
>> work. Python need not be readable by everyone and his grandmother, and
>> it does a fairly good job of being grokkable to someone who has a few
>> ranks in Coding. (Yeah, I'm a D&D nerd. )
> I like what I've seen so far.
Python has its problems, but it's a good language. I personally prefer
to delimit blocks of code with braces than with indentation, and I
also prefer explicit declaration of variables (yes, it's extra work,
but you can have infinitely nested scopes and easily-caught syntax
errors when you misspell one), but they're relatively minor. One of my
favorite aspects of Python is that *everything* is an object. There's
no magic syntax that gives you a piece of an object, or something
special about variables that contain this, that, or the other. A
literal list [like, this, one] can be used in exactly the same ways as
the name of a variable containing a list or a function call returning
a list - there is no difference. Oh how I yearn for that when working
in C++ or PHP!
More information about the Python-list