Python is readable

Alec Taylor alec.taylor6 at gmail.com
Thu Mar 15 12:01:42 EDT 2012


On Fri, Mar 16, 2012 at 1:16 AM, Kiuhnm
<kiuhnm03.4t.yahoo.it at mail.python.org> wrote:
> On 3/15/2012 13:21, Chris Angelico wrote:
>>
>> 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
>
>
> Come on... that was easy! :)
>
>
>> 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.
>
>
> Common people use mainly inclusive intervals as far as I can tell.
> For instance, "from" and "to" are inclusive.
> They could tell you they don't like your intervals because 8-5+1 = 4 instead
> of 3.
>
>
>> 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".
>
>
> But you lose the empty interval (a,a). You're forced to use (a,a-1) or
> something similar. There's always a drawback.
>
>>>> 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,
>
>
> I, on the other hand, prefer indentation. I find braces redundant (in fact,
> I never use them in pseudo-code).
>
>
>> 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.
>
>
> I usually declare my variables but close to where I need them.
>
>
>> 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!
>
>
> Don't worry. Soon you'll be using C++0x :)))
>
> Kiuhnm
> --
> http://mail.python.org/mailman/listinfo/python-list

C++0x? You mean C++11? :P

On that note, is Python upgrading to use C11? :V



More information about the Python-list mailing list