Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52140
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <liuerfire@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | UNSURE 0.332 |
| X-Spam-Level | *** |
| X-Spam-Evidence | '*H*': 0.42; '*S*': 0.08; 'tmp': 0.09; 'clear.': 0.16; 'subject:make': 0.16; 'elements': 0.16; 'thanks.': 0.20; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'twitter:': 0.31; 'received:google.com': 0.35; 'there': 0.35; "didn't": 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'new': 0.61; 'more': 0.64; 'different': 0.65; 'regards.': 0.65; 'here': 0.66; 'beautiful': 0.68; 'skip:r 40': 0.68; 'charset:gb2312': 0.80; 'skip:/ 30': 0.84; 'url:tt': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=wD0uzG2Q8dm7F6pK0gQgGABgd7Kilvql5wvAyuuEu4w=; b=LVeSenpMhuhdMsPsbHrGgDXEQ67V+O30i5zwNIdAJ3HWr4hPe9hPVkCHhhf9OMNZ5B N9cose5lplfLb/ZYeYJSbDJnub4bflfNXuApLI13AJT9Fdd3zZDxJo50Ryd8lPGjDuns CfM0Z2k89IeN4kHOiDbFjBs7gcz9LVX80uCR1u0t8FKyRacKz6ZQ7eAxqLPtLVSVnWEi XeCkzF1gjFEVbO2v4nnZGvU6YtYEd6F+LGd9oDiKlHsCzGEEca9Sa/0mow7BBjXAjoX2 MMUm+PTYJtpQEZcumziy4SXU/n6sFfx8g3+C3SYuq+eZ8sDol1O+rwvIUr0Y0Xd1jDlO +6JA== |
| MIME-Version | 1.0 |
| X-Received | by 10.59.0.2 with SMTP id au2mr653689ved.83.1375865448705; Wed, 07 Aug 2013 01:50:48 -0700 (PDT) |
| Date | Wed, 7 Aug 2013 16:50:48 +0800 |
| Subject | make elements of a list twice or more. |
| From | liuerfire Wang <liuerfire@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=047d7bd750b254358504e357a3b9 |
| X-Mailman-Approved-At | Wed, 07 Aug 2013 18:43:40 +0200 |
| 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.318.1375893821.1251.python-list@python.org> (permalink) |
| Lines | 56 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375893821 news.xs4all.nl 15867 [2001:888:2000:d::a6]:46228 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52140 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Sorry for the title which didn't make clear.
Here is a list x = [b, a, c] (a, b, c are elements of x. Each of them are
different type). Now I wanna generate a new list as [b, b, a, a, c, c].
I know we can do like that:
tmp = []
for i in x:
tmp.append(i)
tmp.append(i)
However, I wander is there a more beautiful way to do it, like [i for i in
x]?
Thanks.
--
Best regards.
/**********************************
google+: +liuerfire <http://gplus.to/onepiece> twitter:
@liuerfire<https://twitter.com/#!/liuerfire>
蛋疼不蛋疼的都可以试着点一下~^_^~ <http://db.tt/YGEdRM0>
***********************************/
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
make elements of a list twice or more. liuerfire Wang <liuerfire@gmail.com> - 2013-08-07 16:50 +0800 Re: make elements of a list twice or more. alex23 <wuwei23@gmail.com> - 2013-08-20 13:42 +1000 Re: make elements of a list twice or more. Tobiah <toby@tobiah.org> - 2013-08-21 13:01 -0700
csiph-web