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


Groups > comp.lang.python > #66836

Re: Remove comma from tuples in python.

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <travisgriggs@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.072
X-Spam-Evidence '*H*': 0.86; '*S*': 0.00; '21,': 0.07; '"if': 0.09; '[x]': 0.16; 'comma': 0.16; 'count,': 0.16; 'fluent': 0.16; 'roy': 0.16; 'subject:Remove': 0.16; 'subject:python.': 0.16; 'torn': 0.16; 'tuple': 0.16; 'unpack': 0.16; 'wrote:': 0.18; 'value.': 0.19; 'written': 0.21; 'feb': 0.22; 'regardless': 0.24; 'second': 0.26; 'read,': 0.26; 'header:In-Reply-To:1': 0.27; 'received:172.16': 0.29; 'am,': 0.29; "i'm": 0.30; 'easier': 0.31; 'you\x92re': 0.31; 'subject:from': 0.34; 'received:google.com': 0.35; 'really': 0.36; 'doing': 0.36; 'message-id:@gmail.com': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; "you're": 0.61; 'header:Message-Id:1': 0.63; 'finally': 0.65; 'charset:windows-1252': 0.65; 'natural': 0.68; 'smith': 0.68; 'article': 0.77; 'as:': 0.81; '"yes,': 0.84; '2014,': 0.84; 'it\x92s': 0.84; 'i\x92ve': 0.84; 'otten': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=8KWnt3+Jm2d6rh5b5NFOsWK+eSFPGxOIOnqCKNNWz40=; b=Dq81eMO6oR6cXrXiIkxEtssAVzmzSdJaUF0amQ0nYpEGdHh5gLu/mVqCnZLEHEju9r EeikBnQNKYTpT0XGhADdNJXr0wU05JJf4qvF92hd77P0bdpBGYDX+G2ehxalJpavhoAD 0EMr5f6GHmEGArzL7JbwEKm5BNfvuwWIx1Axy5zluqGuwjqVtBndKUVInNYaSgeZFZZo yrVphNoblOYl+VgDx7+te8ov5K4Kq+AiY3TiGNLIsqykruwQAbEFHWfI9YxUVAnUc/Fg 06AXggeYUbyS6OH/mQ5mxm10P3XRo+s52VKy+Ho/PjfmWrnGNqniCrtI8x1o93In6/b+ rjSw==
X-Received by 10.66.50.105 with SMTP id b9mr10613417pao.9.1393004928268; Fri, 21 Feb 2014 09:48:48 -0800 (PST)
Content-Type text/plain; charset=windows-1252
Mime-Version 1.0 (Mac OS X Mail 7.1 \(1827\))
Subject Re: Remove comma from tuples in python.
From Travis Griggs <travisgriggs@gmail.com>
In-Reply-To <roy-7DBF08.09321721022014@news.panix.com>
Date Fri, 21 Feb 2014 09:48:42 -0800
Content-Transfer-Encoding quoted-printable
References <8ca893cc-c010-486b-ace3-070ff7ffdac8@googlegroups.com> <mailman.7220.1392971253.18130.python-list@python.org> <qotbny025hh.fsf@ruuvi.it.helsinki.fi> <E%ENu.15087$PQ7.1302@fx29.am4> <20140221080032.67e536f9@bigbox.christie.dr> <mailman.7230.1392992078.18130.python-list@python.org> <roy-7DBF08.09321721022014@news.panix.com>
To python-list@python.org
X-Mailer Apple Mail (2.1827)
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.7231.1393004937.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393004937 news.xs4all.nl 2917 [2001:888:2000:d::a6]:58369
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66836

Show key headers only | View raw


On Feb 21, 2014, at 6:32 AM, Roy Smith <roy@panix.com> wrote:

> In article <mailman.7230.1392992078.18130.python-list@python.org>,
> Peter Otten <__peter__@web.de> wrote:
> 
> 
>> [x*x for (x,) in lst]
>> 
>> [paraphrasing...] can be better written as:
>> 
>> [x*x for [x] in items]
> 
> I'm torn between, "Yes, the second form is distinctly easier to read" 
> and, "If you think the second form is easier to read, you're admitting 
> you're not really fluent in Python”.

I’ve used the comma form with struct.unpack() frequently:

count, = struct.unpack(‘!I’, self.packet)

That’s after I don’t use it and end up scratching my head for a while and finally remember that unpack returns a tuple regardless of how many things I unpack from it. It’s just natural if you’re doing lots of single unpacks to think it returns a single value. Either way, I much prefer it to:

count = struct.unpack(‘!I’, self.packet)[0]

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


Thread

Remove comma from tuples in python. Jaydeep Patil <patil.jay2009@gmail.com> - 2014-02-20 22:49 -0800
  Re: Remove comma from tuples in python. Mircescu Andrei <mircescu.andrei@gmail.com> - 2014-02-20 23:02 -0800
    Re: Remove comma from tuples in python. Stephane Wirtel <stephane@wirtel.be> - 2014-02-21 08:11 +0100
    Re: Remove comma from tuples in python. Bernd Nawothnig <Bernd.Nawothnig@t-online.de> - 2014-02-21 08:20 +0100
  Re: Remove comma from tuples in python. Gary Herron <gary.herron@islandtraining.com> - 2014-02-21 00:27 -0800
    Re: Remove comma from tuples in python. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-21 11:13 +0200
      Re: Remove comma from tuples in python. Alister <alister.ware@ntlworld.com> - 2014-02-21 09:29 +0000
        Re: Remove comma from tuples in python. Tim Chase <python.list@tim.thechases.com> - 2014-02-21 08:00 -0600
        Re: Remove comma from tuples in python. Peter Otten <__peter__@web.de> - 2014-02-21 15:14 +0100
          Re: Remove comma from tuples in python. Roy Smith <roy@panix.com> - 2014-02-21 09:32 -0500
            Re: Remove comma from tuples in python. Travis Griggs <travisgriggs@gmail.com> - 2014-02-21 09:48 -0800
            Re: Remove comma from tuples in python. Tim Chase <python.list@tim.thechases.com> - 2014-02-21 12:07 -0600
            Re: Remove comma from tuples in python. Cameron Simpson <cs@zip.com.au> - 2014-02-24 12:19 +1100
  Re: Remove comma from tuples in python. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-21 14:02 +0000

csiph-web