Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Slicing history?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Aahz  
View profile  
 More options Nov 15, 1:50 pm
Newsgroups: comp.lang.python
From: a...@pythoncraft.com (Aahz)
Date: 15 Nov 2009 10:50:43 -0800
Local: Sun, Nov 15 2009 1:50 pm
Subject: Slicing history?
Anyone remember or know why Python slices function like half-open
intervals?  I find it incredibly convenient myself, but an acquaintance
familiar with other programming languages thinks it's bizarre and I'm
wondering how it happened.
--
Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/

[on old computer technologies and programmers]  "Fancy tail fins on a
brand new '59 Cadillac didn't mean throwing out a whole generation of
mechanics who started with model As."  --Andrew Dalke


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Clements  
View profile  
 More options Nov 15, 2:01 pm
Newsgroups: comp.lang.python
From: Jon Clements <jon...@googlemail.com>
Date: Sun, 15 Nov 2009 11:01:49 -0800 (PST)
Local: Sun, Nov 15 2009 2:01 pm
Subject: Re: Slicing history?
On Nov 15, 6:50 pm, a...@pythoncraft.com (Aahz) wrote:

> Anyone remember or know why Python slices function like half-open
> intervals?  I find it incredibly convenient myself, but an acquaintance
> familiar with other programming languages thinks it's bizarre and I'm
> wondering how it happened.
> --
> Aahz (a...@pythoncraft.com)           <*>        http://www.pythoncraft.com/

> [on old computer technologies and programmers]  "Fancy tail fins on a
> brand new '59 Cadillac didn't mean throwing out a whole generation of
> mechanics who started with model As."  --Andrew Dalke

Good ol' zero based indexing. It makes a lot more sense that range(len
(my_list)) returns 'n' values which are valid indicies, otherwise
they'd be a lot of IndexError's being raised.

Besides, when you really want the full range (a corner case), it's a
lot easier to do a +1, than to force people to write -1 for the vast
majority of cases.

Jon.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nobody  
View profile  
 More options Nov 15, 2:19 pm
Newsgroups: comp.lang.python
From: Nobody <nob...@nowhere.com>
Date: Sun, 15 Nov 2009 19:19:01 +0000
Local: Sun, Nov 15 2009 2:19 pm
Subject: Re: Slicing history?

On Sun, 15 Nov 2009 10:50:43 -0800, Aahz wrote:
> Anyone remember or know why Python slices function like half-open
> intervals?  I find it incredibly convenient myself, but an acquaintance
> familiar with other programming languages thinks it's bizarre and I'm
> wondering how it happened.

How else would they function? Closed intervals?

Using a closed interval (for just about anything) indicates that the
designer has very limited programming experience. Anyone with a modicum of
programming experience knows that half-open intervals are the norm, and
that using closed intervals will confuse anyone else with a modicum of
programming experience.

That's aside from the objective merits, i.e. the fact that they can be
used to partition an interval into subintervals without having to
adjust the upper bound (which requires knowing how much to adjust the
upper bound by, if that's even possible (for reals, it isn't)).


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Dickinson  
View profile  
 More options Nov 15, 3:11 pm
Newsgroups: comp.lang.python
From: Mark Dickinson <dicki...@gmail.com>
Date: Sun, 15 Nov 2009 12:11:40 -0800 (PST)
Local: Sun, Nov 15 2009 3:11 pm
Subject: Re: Slicing history?
On Nov 15, 6:50 pm, a...@pythoncraft.com (Aahz) wrote:

> Anyone remember or know why Python slices function like half-open
> intervals?  I find it incredibly convenient myself, but an acquaintance
> familiar with other programming languages thinks it's bizarre and I'm
> wondering how it happened.

Sounds like an excuse to post this Dijkstra link:

http://www.cs.utexas.edu/~EWD/ewd08xx/EWD831.PDF

--
Mark


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Howell  
View profile  
 More options Nov 15, 3:40 pm
Newsgroups: comp.lang.python
From: Steve Howell <showel...@yahoo.com>
Date: Sun, 15 Nov 2009 12:40:44 -0800 (PST)
Local: Sun, Nov 15 2009 3:40 pm
Subject: Re: Slicing history?
On Nov 15, 12:11 pm, Mark Dickinson <dicki...@gmail.com> wrote:

> On Nov 15, 6:50 pm, a...@pythoncraft.com (Aahz) wrote:

> > Anyone remember or know why Python slices function like half-open
> > intervals?  I find it incredibly convenient myself, but an acquaintance
> > familiar with other programming languages thinks it's bizarre and I'm
> > wondering how it happened.

> Sounds like an excuse to post this Dijkstra link:

> http://www.cs.utexas.edu/~EWD/ewd08xx/EWD831.PDF

That is really good stuff!  Like Aahz I have Python's slicing
mechanism (and zero-based indexing) burnt into my brain, but I never
had a good way to explain why it makes sense, other than just an
intuitive notion that it works for me.  It is interesting how the link
actually seems to explain zero-based indexing as a consequence of the
slicing approach, not a cause.  I always understood zero-based
indexing as a relic of memory management, which was fine, but I guess
the reasons go deeper than that.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aahz  
View profile  
 More options Nov 15, 5:06 pm
Newsgroups: comp.lang.python
From: a...@pythoncraft.com (Aahz)
Date: 15 Nov 2009 14:06:47 -0800
Local: Sun, Nov 15 2009 5:06 pm
Subject: Re: Slicing history?
In article <667394cb-d505-4906-8c6b-ab2d361b3...@j24g2000yqa.googlegroups.com>,
Mark Dickinson  <dicki...@gmail.com> wrote:

>On Nov 15, 6:50=A0pm, a...@pythoncraft.com (Aahz) wrote:

>> Anyone remember or know why Python slices function like half-open
>> intervals? =A0I find it incredibly convenient myself, but an acquaintance
>> familiar with other programming languages thinks it's bizarre and I'm
>> wondering how it happened.

>Sounds like an excuse to post this Dijkstra link:

>http://www.cs.utexas.edu/~EWD/ewd08xx/EWD831.PDF

Many thanks!
--
Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it."  --Brian W. Kernighan


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google