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


Groups > comp.lang.python > #17331

Re: How to generate "a, b, c, and d"?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'received:verizon.net': 0.07; 'terry': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.12; '16,': 0.15; '"and': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'removed.': 0.24; 'second': 0.29; 'pm,': 0.29; 'chris': 0.30; 'least': 0.30; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'there': 0.33; 'fri,': 0.34; 'to:addr:python-list': 0.34; 'subject:How': 0.35; 'skip:" 10': 0.37; 'two': 0.37; 'received:org': 0.38; 'to:addr:python.org': 0.40; '2011': 0.61; '11:57': 0.84; 'replacements': 0.84; 'items,': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: How to generate "a, b, c, and d"?
Date Fri, 16 Dec 2011 00:26:10 -0500
References <9393353.282.1323967703697.JavaMail.geo-discussion-forums@vbyc2> <4EEA2DF2.9080107@mrabarnett.plus.com> <jce51p$5t4$1@dough.gmane.org> <CAPTjJmpf6ouOe7Ku=CoEVdh4X4iqxwMTW+z81FxdAGUQE7qZBQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-74-109-121-73.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <CAPTjJmpf6ouOe7Ku=CoEVdh4X4iqxwMTW+z81FxdAGUQE7qZBQ@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.3714.1324013192.27778.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324013192 news.xs4all.nl 6928 [2001:888:2000:d::a6]:55603
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17331

Show key headers only | View raw


On 12/15/2011 9:42 PM, Chris Angelico wrote:
> On Fri, Dec 16, 2011 at 11:57 AM, Terry Reedy<tjreedy@udel.edu>  wrote:
>>   items[-1] = "and " + items[-1]
>>   return ", ".join(items)
>
> This works only if you're sure there are at least two items, and if
> you don't mind two items coming out as "a, and b".

Please read the context that you removed.
The original second return line and my replacements come after

if len(items) <= 2:
   return " and ".join(items)

-- 
Terry Jan Reedy

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


Thread

How to generate "a, b, c, and d"? Roy Smith <roy@panix.com> - 2011-12-15 08:48 -0800
  Re: How to generate "a, b, c, and d"? MRAB <python@mrabarnett.plus.com> - 2011-12-15 17:27 +0000
  Re: How to generate "a, b, c, and d"? Tim Chase <python.list@tim.thechases.com> - 2011-12-15 12:01 -0600
  Re: How to generate "a, b, c, and d"? Ethan Furman <ethan@stoneleaf.us> - 2011-12-15 10:19 -0800
  Re: How to generate "a, b, c, and d"? Tim Chase <python.list@tim.thechases.com> - 2011-12-15 12:51 -0600
    Re: How to generate "a, b, c, and d"? Roy Smith <roy@panix.com> - 2011-12-15 11:01 -0800
    Re: How to generate "a, b, c, and d"? Roy Smith <roy@panix.com> - 2011-12-15 11:01 -0800
  Re: How to generate "a, b, c, and d"? MRAB <python@mrabarnett.plus.com> - 2011-12-15 19:27 +0000
  Re: How to generate "a, b, c, and d"? Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-15 14:22 -0700
  Re: How to generate "a, b, c, and d"? Terry Reedy <tjreedy@udel.edu> - 2011-12-15 19:57 -0500
  Re: How to generate "a, b, c, and d"? Chris Angelico <rosuav@gmail.com> - 2011-12-16 13:42 +1100
  Re: How to generate "a, b, c, and d"? Terry Reedy <tjreedy@udel.edu> - 2011-12-16 00:26 -0500

csiph-web