Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86240
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: Concatenate list values |
| Date | 2015-02-23 17:13 +0000 |
| References | <12821378-62af-4954-8b61-aa0738c5ff5c@googlegroups.com> <20150223101434.52871fcc@bigbox.christie.dr> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.19084.1424711656.18130.python-list@python.org> (permalink) |
On 23/02/2015 16:14, Tim Chase wrote: > On 2015-02-23 07:58, loial wrote: >> Is there a quick way to concatenate all the values in a list into a >> string, except the first value? >> >> I want this to work with variable length lists. >> >> All values in list will be strings. > > Using > > "".join(my_list[1:]) > > should work. > > If it is an arbitrary iterable instead of a list (and thus can't be > sliced), you can use > > "".join(itertools.islice(my_iter, 1, None)) > > -tkc > Presumably rather more efficient for long lists as you're not taking a copy of (effectively) the entire list. Any volunteers to measure it, not mentioning any names, Mr D'Aprano? :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Concatenate list values loial <jldunn2000@gmail.com> - 2015-02-23 07:58 -0800
Re: Concatenate list values John Gordon <gordon@panix.com> - 2015-02-23 16:07 +0000
Re: Concatenate list values alister <alister.nospam.ware@ntlworld.com> - 2015-02-23 16:08 +0000
Re: Concatenate list values Peter Otten <__peter__@web.de> - 2015-02-23 17:09 +0100
Re: Concatenate list values Tim Chase <python.list@tim.thechases.com> - 2015-02-23 10:14 -0600
Re: Concatenate list values Andrew Berg <aberg010@my.hennepintech.edu> - 2015-02-23 10:14 -0600
Re: Concatenate list values Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-23 17:13 +0000
Re: Concatenate list values wxjmfauth@gmail.com - 2015-02-24 02:30 -0800
Re: Concatenate list values loial <jldunn2000@gmail.com> - 2015-02-24 00:37 -0800
csiph-web