Python Feature Request: Allow changing base of member indices to 1

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Roberts

    #31
    Re: Python Feature Request: Allow changing base of member indices to 1

    "Beliavsky" <beliavsky@aol. comwrote:
    >
    >Fortran has allowed a user-specified base since at least the 1977
    >standard -- see for example http://www.umiacs.umd.edu/~jhu/DOCS/...l/essl159.html
    >.
    You can strike "at least"; this extension was introduced in FORTRAN 77.
    FORTRAN 66 didn't do this.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    • Dustan

      #32
      Re: Python Feature Request: Allow changing base of member indices to 1

      On Apr 14, 4:06 pm, Bjoern Schliessmann <usenet-
      mail-0306.20.chr0n.. .@spamgourmet.c omwrote:
      jamadagni wrote:
      OK fine. It is clear that this feature must be implemented if at
      all only on a per-module basis. So can we have votes for
      per-module implementation of this feature?
      >
      I don't think it's worth the hassle. BTW, what's, IYHO, the distinct
      advantage of starting array indices at 1?
      For newbies, it's easier to count starting with 1. It's rather
      unintuitive to start at 0.

      That's not to say that I support this feature request; I got used to
      counting from 0. It just took me some time.
      Regards,
      >
      Björn
      >
      --
      BOFH excuse #90:
      >
      Budget cuts

      Comment

      • Zara

        #33
        Re: Python Feature Request: Allow changing base of member indices to 1

        On Mon, 16 Apr 2007 10:15:19 +0200, "Javier Bezos"
        <see_below_no_s pam@yahoo.eswro te:
        >Paddy,
        >
        >>Dijkstra's argument is obsolete, as it is based on
        >>how array length was computed many years ago -- if
        >>we have an array a = b..e, then the lenght of a
        >>is e-b (half open range). Good at low level
        >>programming .
        >>>
        >>But a quarter of a century after we know concepts
        >>are much better than low level programming and
        >>explicit computations -- if we have an array
        >>a = b..e, then the length of a should be a.length()
        >>(or a.length(b,e)), and it is independent of
        >
        >Hi Javier,
        >You seem to have missed out array *indexing*
        >in your argument, or is array indexing obsolete?
        >
        >Of course, it isn't, but it has evolved over the
        >past 25 years. When Djikstra wrote that, many
        >people (including me) was using a Spectrum---
        >Now we have OO programming to deal with concepts
        >and a more generic programming. So, to me it's
        >clear his _argument_ is very outdated and cannot
        >be applied directly and withot reservations to
        >modern languages like Python.
        >

        One language created by and for mathematicians: Haskell.
        It uses zero based list indexing (the most similar to array indexing
        they have), so that list!!0 is the first element and list!!3 the
        fourth element.

        And they tend to reason in Dijkstra's style. They love natural numbers
        beginning with zer:

        zara

        Comment

        • Antoon Pardon

          #34
          Re: Python Feature Request: Allow changing base of member indices to 1

          On 2007-04-14, Paddy <paddy3118@goog lemail.comwrote :
          On Apr 14, 11:27 am, samj...@gmail.c om wrote:
          >This is like the previous one. Please check for sanity and approve for
          >posting at python-dev.
          >>
          >I would like to have something like "option base" in Visual Basic.
          >IIRC it used to allow me to choose whether 0 or 1 should be used as
          >the base of member indices of arrays. In Python, the same can be used
          >with strings, lists, tuples etc.
          >>
          >This would mean:
          >foo = "foo"
          >=foo[1] == 'f'
          >>
          >foo = ['foo', 'bar', 'spam' ]
          >=foo[1] == 'foo'
          >>
          >foo = ('spam', 'eggs')
          >=foo[1] == 'spam'
          >>
          >For convenience it should also affect the range function so that:
          >>
          >range(3) = [1, 2, 3]
          >>
          >because this is often used where arrays would be used in VB.
          >>
          >Finally, when the programmer does not specify his choice of base at
          >the beginning of the program, the current behaviour of using 0 as base
          >should continue so that there is no problem with backward
          >compatibilit y.
          >
          Here is a document giving good reasons for indexing to start at
          zero, as in Python.
          I find he just picks the reasons he agrees with.

          If you pick your values as a <= i <= b it has the advantage that
          the bounds are explicit. No need to add or substract 1 from
          one of the values to get the exact boundis. Now how much weight
          you want to give this characteristic is open for debate but
          the fact that it isn't even mentioned doesn't give me much
          confidence in the author's ability to weight all the pro's
          and con's.

          The author has done a bit:

          >
          Having more than one index start point would be a maintenance
          nightmare best avoided. (It can be done in Perl).
          It was never a problem when I still programmed in Pascal.

          --
          Antoon Pardon

          Comment

          • Bjoern Schliessmann

            #35
            Re: Python Feature Request: Allow changing base of member indices to 1

            Dustan wrote:
            For newbies, it's easier to count starting with 1. It's rather
            unintuitive to start at 0.
            Cool. So Python will become a "newbie language", and everyone
            that "jumps" from Python to a different language will have to
            relearn 0-based indices? ;)

            Regards,


            Björn

            --
            BOFH excuse #418:

            Sysadmins busy fighting SPAM.

            Comment

            Working...