Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; '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; '>>>': 0.18; 'object.': 0.22; 'sorry,': 0.22; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'obj': 0.29; 'this.': 0.29; "i'm": 0.29; 'code': 0.31; 'point': 0.31; 'problem': 0.33; 'list': 0.35; 'message-id:@gmail.com': 0.36; "didn't": 0.36; 'data': 0.37; 'subject:: ': 0.38; 'apply': 0.39; 'john': 0.60; 'between': 0.63; 'received:ac.uk': 0.65; 'wanting': 0.65; '2013': 0.84; 'oscar': 0.84; 'reid': 0.84; 'engines.': 0.91; 'to:none': 0.93 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.ucs.cam.ac.uk/email/scanner/ Date: Mon, 18 Feb 2013 13:49:12 +0000 From: John Reid User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 CC: Python List Subject: Re: Differences creating tuples and collections.namedtuples References: <7a40a426-baa9-46f8-8f9d-59ba32b044f3@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: "J.E. Reid" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361195360 news.xs4all.nl 6912 [2001:888:2000:d::a6]:58383 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39090 On 18/02/13 12:05, Oscar Benjamin wrote: > On 18 February 2013 12:03, Oscar Benjamin wrote: >> On 18 February 2013 11:47, John Reid 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? > > Well like I said it is not me that wants to do this. It is part of the code in IPython for sending messages between clients and engines.