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


Groups > comp.lang.python > #39084

Re: Differences creating tuples and collections.namedtuples

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'elements.': 0.05; 'properly.': 0.07; 'preserve': 0.09; 'tuple': 0.09; 'cc:addr :python-list': 0.10; 'def': 0.10; 'above?': 0.16; 'benjamin': 0.16; 'cc:name:python list': 0.16; 'wrote:': 0.17; 'object.': 0.22; 'sorry,': 0.22; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'obj': 0.29; "i'm": 0.29; 'code': 0.31; 'point': 0.31; 'problem': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'received:209.85': 0.35; "didn't": 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'apply': 0.39; 'john': 0.60; 'wanting': 0.65; '2013': 0.84; 'oscar': 0.84; 'reid': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=WpQb6TWGosfW8JDrSBXHqsWFV9wGgHKHG/HtkmvVetI=; b=s792GYt1foQw/qc7vX6nUuDeQEUXicF2iYwpbnFXJ5Pa/vqmN4/Rs5rUiVWiVQVloi xmcscR6uIlmukDbWTtFQkubvE17/CsvYkf14GhJ/6Bp25T665ryifGwDGUtfDDjCaadP +O+PsVhpTQQX6FjZN5vn7Z67wWMV3Vx+JwkZa5SnnuQREcwHYW2tPmFAW51OeEphTCTp uEBmiRamL2cfJHGQCImK57zst9AJbrkQe4fnDxDvKR/YfXvgPDcrN0LRh+X5dJznqx5V x7yHT7Uq6AvS73Wyf8FpLW91hA+BWJwcPFF8EYqUZjON+Cvf2EpBkAa29J0Qn2JIo3OK FwAQ==
X-Received by 10.52.89.83 with SMTP id bm19mr13109433vdb.123.1361189132043; Mon, 18 Feb 2013 04:05:32 -0800 (PST)
MIME-Version 1.0
In-Reply-To <CAHVvXxQ1rmKk8djCZj-O3XhJwifHNYyR7JLTgfw_hKQzcoo=bA@mail.gmail.com>
References <7a40a426-baa9-46f8-8f9d-59ba32b044f3@googlegroups.com> <CAHVvXxQ1rmKk8djCZj-O3XhJwifHNYyR7JLTgfw_hKQzcoo=bA@mail.gmail.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Mon, 18 Feb 2013 12:05:11 +0000
Subject Re: Differences creating tuples and collections.namedtuples
To John Reid <johnbaronreid@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Cc Python List <python-list@python.org>
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.1935.1361189141.2939.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361189141 news.xs4all.nl 6885 [2001:888:2000:d::a6]:36613
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39084

Show key headers only | View raw


On 18 February 2013 12:03, Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:
> On 18 February 2013 11:47, John Reid <johnbaronreid@gmail.com> wrote:
>> I'm seeing this problem because of the following code in IPython:
>>
>> def canSequence(obj):
>>     if isinstance(obj, (list, tuple)):
>>         t = type(obj)
>>         return t([can(i) for i in obj])
>>     else:
>>         return obj
>
> What is the point of the code above? If obj is a list or a tuple you
> create a new list or tuple with the same data and then return it
> otherwise you just return the object. What about:

Sorry, I didn't read this properly. I see that you want apply can() to
all the elements. What is the reason for wanting to preserve the type
of the sequence?


Oscar

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


Thread

Differences creating tuples and collections.namedtuples John Reid <johnbaronreid@gmail.com> - 2013-02-18 03:47 -0800
  Re: Differences creating tuples and collections.namedtuples Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-18 12:03 +0000
  Re: Differences creating tuples and collections.namedtuples Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-18 12:05 +0000
  Re: Differences creating tuples and collections.namedtuples Dave Angel <davea@davea.name> - 2013-02-18 07:11 -0500
  Re: Differences creating tuples and collections.namedtuples John Reid <johnbaronreid@gmail.com> - 2013-02-18 13:49 +0000
  Re: Differences creating tuples and collections.namedtuples John Reid <johnbaronreid@gmail.com> - 2013-02-18 13:51 +0000
  Re: Differences creating tuples and collections.namedtuples John Reid <j.reid@mail.cryst.bbk.ac.uk> - 2013-02-18 14:09 +0000
    Re: Differences creating tuples and collections.namedtuples raymond.hettinger@gmail.com - 2013-02-18 23:48 -0800
      Re: Differences creating tuples and collections.namedtuples Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-19 08:06 +0000
      Re: Differences creating tuples and collections.namedtuples Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-19 08:57 +0000
      Re: Differences creating tuples and collections.namedtuples Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-19 08:06 +0000
      Re: Differences creating tuples and collections.namedtuples Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-19 08:05 +0000
    Re: Differences creating tuples and collections.namedtuples raymond.hettinger@gmail.com - 2013-02-18 23:48 -0800
  Re: Differences creating tuples and collections.namedtuples Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-18 14:15 +0000
  Re: Differences creating tuples and collections.namedtuples John Reid <johnbaronreid@gmail.com> - 2013-02-18 14:18 +0000
  Re: Differences creating tuples and collections.namedtuples Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-18 14:12 +0000
  Re: Differences creating tuples and collections.namedtuples John Reid <j.reid@mail.cryst.bbk.ac.uk> - 2013-02-18 14:23 +0000
  Re: Differences creating tuples and collections.namedtuples Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-18 14:53 +0000
  Re: Differences creating tuples and collections.namedtuples John Reid <j.reid@mail.cryst.bbk.ac.uk> - 2013-02-18 15:07 +0000
  Re: Differences creating tuples and collections.namedtuples Terry Reedy <tjreedy@udel.edu> - 2013-02-18 16:28 -0500
    Re: Differences creating tuples and collections.namedtuples Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-19 11:18 +1100
      Re: Differences creating tuples and collections.namedtuples Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-19 01:43 +0000
        Re: Differences creating tuples and collections.namedtuples Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-19 14:06 +1100
          Re: Differences creating tuples and collections.namedtuples Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-02-19 21:27 +1300
      Re: Differences creating tuples and collections.namedtuples Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-02-19 20:54 +1300
      Re: Differences creating tuples and collections.namedtuples John Reid <j.reid@mail.cryst.bbk.ac.uk> - 2013-02-19 09:30 +0000
      Re: Differences creating tuples and collections.namedtuples Terry Reedy <tjreedy@udel.edu> - 2013-02-19 22:38 -0500
        Re: Differences creating tuples and collections.namedtuples Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-22 10:38 +0000
      Re: Differences creating tuples and collections.namedtuples Chris Angelico <rosuav@gmail.com> - 2013-02-20 17:50 +1100
        Re: Differences creating tuples and collections.namedtuples Roy Smith <roy@panix.com> - 2013-02-20 09:09 -0500
    Re: Differences creating tuples and collections.namedtuples Roy Smith <roy@panix.com> - 2013-02-18 20:11 -0500
  Re: Differences creating tuples and collections.namedtuples alex23 <wuwei23@gmail.com> - 2013-02-18 17:47 -0800
    Re: Differences creating tuples and collections.namedtuples John Reid <j.reid@mail.cryst.bbk.ac.uk> - 2013-02-19 09:36 +0000

csiph-web