Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43888

Re: The type/object distinction and possible synthesis of OOP and imperative programming languages

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'initialize': 0.07; 'string': 0.09; 'exception.': 0.09; 'yeah,': 0.09; 'crashed': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'indexerror:': 0.16; 'segfault': 0.16; 'subject: \n ': 0.16; 'subject:OOP': 0.16; 'subject:object': 0.16; 'subject:possible': 0.16; 'subject:programming': 0.16; 'subject:type': 0.16; 'index': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'subject:/': 0.26; 'header:In- Reply-To:1': 0.27; 'forgot': 0.30; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; 'file': 0.32; '(most': 0.33; 'fri,': 0.33; 'could': 0.34; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'skip:u 10': 0.60; 'expression': 0.60; 'most': 0.60; 'range': 0.61; 'subject:The': 0.64; 'rusi': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=dGHS1mm6uv/Yi20u7hscJgOiUzP4eLvr+M7a4NFH0x0=; b=nb8NKzhJRVFCmHPzGHVc0wQ6+L3hbKOBH7fURWWadcvE/m5bHrRv0MKiidYM2T4noX rEZ3zh8JwK39atb7oy0mXYnxbGdnHs7JARMeWcqDpVZQAakbxeFWessQPrgLALLzWydo j+gozt0BRF0gXH2pgcm/UeTmI5zkiHPcoEND9LgKMMrOgUJiszjO2TMuFmnZcCw6maAG CIMHv+Vwt8gKlmt9IVTR90e/EyYAgwv/xMiRs04g9Rnms57Car+6iltnJy2VcJwlpzea cRiFaCnVzis+pWQxjrFHV/hFCwkz/eW/q5txc6NIf0JimqAQdXfZapocKZQt2qR6XRBY OTWw==
MIME-Version 1.0
X-Received by 10.68.189.163 with SMTP id gj3mr17223671pbc.207.1366355141651; Fri, 19 Apr 2013 00:05:41 -0700 (PDT)
In-Reply-To <10511876-84bf-41f5-ad96-cf4ee5a6973e@di5g2000pbc.googlegroups.com>
References <CAMjeLr_7A-NRtec=K_ZsjXA_oJHnD6+vpttz4Ma0vtDRbb+o2w@mail.gmail.com> <CAOvMSvXy=iJhUtMfncv-RE3HQw+7DJO-M1-TaeAFFhnDe9mpUA@mail.gmail.com> <BLU173-W31425FA225FA31B42E5B91CDCC0@phx.gbl> <mailman.804.1366325597.3114.python-list@python.org> <10511876-84bf-41f5-ad96-cf4ee5a6973e@di5g2000pbc.googlegroups.com>
Date Fri, 19 Apr 2013 17:05:41 +1000
Subject Re: The type/object distinction and possible synthesis of OOP and imperative programming languages
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.815.1366355144.3114.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366355144 news.xs4all.nl 2222 [2001:888:2000:d::a6]:49731
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43888

Show key headers only | View raw


On Fri, Apr 19, 2013 at 1:35 PM, rusi <rustompmody@gmail.com> wrote:
> If I have a loop:
>
>  while i < len(a) and a[i] != x:
>    i++
>
> I need to understand that at the end of the loop:
> i >= len(a) or a[i] == x
> and not
> i >= len(a) and a[i] == x
> nor
> i == len(a) or a[i] == x  # What if I forgot to initialize i?

Or your program has crashed out with an exception.

>>> i,a,x=-10,"test","q"
>>> while i < len(a) and a[i] != x:
	i+=1

Traceback (most recent call last):
  File "<pyshell#69>", line 1, in <module>
    while i < len(a) and a[i] != x:
IndexError: string index out of range

Or if that had been in C, it could have bombed with a segfault rather
than a nice tidy exception. Definitely initialize i.

But yeah, the basis of algebra is helpful, even critical, to
understanding most expression evaluators.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [TYPES] The type/object distinction and possible synthesis of OOP and imperative programming languages Mark Janssen <dreamingforward@gmail.com> - 2013-04-18 15:53 -0700
  Re: The type/object distinction and possible synthesis of OOP and imperative programming languages rusi <rustompmody@gmail.com> - 2013-04-18 20:35 -0700
    Re: The type/object distinction and possible synthesis of OOP and imperative programming languages Mark Janssen <dreamingforward@gmail.com> - 2013-04-18 20:58 -0700
    Re: The type/object distinction and possible synthesis of OOP and imperative programming languages Chris Angelico <rosuav@gmail.com> - 2013-04-19 17:05 +1000
    Re: The type/object distinction and possible synthesis of OOP and imperative programming languages Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-04-19 18:58 -0400

csiph-web