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


Groups > comp.lang.python > #85808

Re: What the Pythons docs means by "container" ?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.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 <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'mrab': 0.05; 'read-only': 0.09; 'python': 0.11; 'conformance': 0.16; 'container.': 0.16; 'containers': 0.16; 'docstring': 0.16; 'integers.': 0.16; 'iterating': 0.16; 'length.': 0.16; 'sequence.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '(the': 0.22; 'feb': 0.22; '>>>': 0.22; 'comparing': 0.24; 'instance,': 0.24; 'string,': 0.24; 'looks': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'returned': 0.30; 'message- id:@mail.gmail.com': 0.30; 'container': 0.31; 'so-called': 0.31; 'view.': 0.31; 'another': 0.32; 'actual': 0.34; 'subject:the': 0.34; 'agree': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'definition': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'object,': 0.36; 'view,': 0.36; 'virtual': 0.37; 'so,': 0.37; 'list': 0.37; 'received:209': 0.37; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'most': 0.60; 'range': 0.61; 'kind': 0.63; 'here': 0.66; '2015': 0.84; 'approach.': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=QgWfwoQmdMykPkZ0vbHMWGOBEdf5ZCSCkLNQyfnmdW8=; b=SX91QztAk1AUzw9NOIF03wvgWEFEcWYMPdaC62ds9lJrI8Bc2gzNuPn/Xsj0/GTSA3 t/7CDTIakxnMnChntEBpzfcsO7SjZ3ZSLclbnHAFcH1iVk9duihX8v5haYmJ45lDFupP lXFr+lXYahXQsCP17Z0Xd7uuAb3TkdKzxJy7YYwrQp5LG0uY97ulOE9bgxyAdhqyd1U0 9fpA7Eq8vrmQDkgqoQ/LcqOOUu8WxSQ8vecSVsmrs5GkYjYvBe9jNlV6aSiyLWi7vP1X WlF7jodknn30e5ReT7KJ/qBhs92ghzbkuGpQw13txqBhp/NTus/7yhtQExZJihedjmcb XVZg==
X-Received by 10.66.120.47 with SMTP id kz15mr1017379pab.35.1424285497144; Wed, 18 Feb 2015 10:51:37 -0800 (PST)
MIME-Version 1.0
In-Reply-To <54E4D418.5030109@mrabarnett.plus.com>
References <71e8463f-2a60-4fb0-a5b7-0ca7cd3efece@googlegroups.com> <mailman.18794.1424209210.18130.python-list@python.org> <472c49ae-c2ce-4eda-b922-f16613722e31@googlegroups.com> <mailman.18798.1424220589.18130.python-list@python.org> <1d87da9c-ef64-4bd2-9179-e2aad908a9d0@googlegroups.com> <54E4D418.5030109@mrabarnett.plus.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 18 Feb 2015 11:50:56 -0700
Subject Re: What the Pythons docs means by "container" ?
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18829.1424285506.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424285506 news.xs4all.nl 2915 [2001:888:2000:d::a6]:41369
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85808

Show key headers only | View raw


On Wed, Feb 18, 2015 at 11:04 AM, MRAB <python@mrabarnett.plus.com> wrote:
> On 2015-02-18 02:14, candide wrote:
>>
>> Le mercredi 18 février 2015 01:50:16 UTC+1, Chris Angelico a écrit :
>>
>>> So, what's a container? It's a thing that you put other objects
>>> into.
>>
>>
>> I agree with this approach. The important point to consider here is
>> the last word in your definition : "into". There is the container and
>> there is the content (the objects into). The so-called built-in
>> containers (list, string, etc) are in conformance with this view.
>> Now, regarding a range object as a container disagrees completely
>> with the definition given in the PLR : there is no contents and hence
>> there is no container. For instance, range(10**6) doesn't hold any
>> kind of object, there are no reference to the int objects 0, 1, 2,
>> ... As the range's docstring explains, range returns a VIRTUAL
>> sequence.
>>
> It's a virtual, read-only container that contains integers.
>
> Try comparing range(10) with tuple(range(10)). Both contain integers.
> Both have a length. Both can be indexed.

Another way to look at range is as an optimization of the range from
Python 2, which returned an actual list of integers. Most callers are
only interested in iterating over the container and don't have to be
concerned whether the result is actually a list or just something that
looks enough like one for their purposes. From that point of view, a
range object is still a container.

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


Thread

What the Pythons docs means by "container" ? candide <c.candide@laposte.net> - 2015-02-17 13:21 -0800
  Re: What the Pythons docs means by "container" ? Cameron Simpson <cs@zip.com.au> - 2015-02-18 08:39 +1100
    Re: What the Pythons docs means by "container" ? candide <c.candide@laposte.net> - 2015-02-17 16:30 -0800
      Re: What the Pythons docs means by "container" ? Chris Angelico <rosuav@gmail.com> - 2015-02-18 11:49 +1100
        Re: What the Pythons docs means by "container" ? candide <pascal.ortiz@gmail.com> - 2015-02-17 18:14 -0800
          Re: What the Pythons docs means by "container" ? MRAB <python@mrabarnett.plus.com> - 2015-02-18 18:04 +0000
          Re: What the Pythons docs means by "container" ? Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-18 11:50 -0700
          Re: What the Pythons docs means by "container" ? Ethan Furman <ethan@stoneleaf.us> - 2015-02-18 11:43 -0800
          Re: What the Pythons docs means by "container" ? Terry Reedy <tjreedy@udel.edu> - 2015-02-18 15:04 -0500
            Re: What the Pythons docs means by "container" ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-19 10:03 +1100
              Re: What the Pythons docs means by "container" ? Ben Finney <ben+python@benfinney.id.au> - 2015-02-19 11:05 +1100
              Re: What the Pythons docs means by "container" ? Chris Angelico <rosuav@gmail.com> - 2015-02-19 11:33 +1100
  Re: What the Pythons docs means by "container" ? Terry Reedy <tjreedy@udel.edu> - 2015-02-17 19:54 -0500
  Re: What the Pythons docs means by "container" ? perfectican <perfectican@gmail.com> - 2015-02-19 02:59 -0800
    Re: What the Pythons docs means by "container" ? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-19 11:20 +0000
  Re: What the Pythons docs means by "container" ? Rustom Mody <rustompmody@gmail.com> - 2015-02-20 03:37 -0800
    Re: What the Pythons docs means by "container" ? Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-20 11:38 -0700

csiph-web