Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97110
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: Python, convert an integer into an index? |
| Date | 2015-09-24 21:26 -0400 |
| Organization | IISS Elusive Unicorn |
| References | (1 earlier) <201509222221.t8MMLMi5015927@fido.openend.se> <mailman.87.1442977993.28679.python-list@python.org> <vg3pp18x8e6.fsf@coffee.modeemi.fi> <5603FAEE.1060101@mrabarnett.plus.com> <CAJ4+4aqWJA6ktbD49i_hqa4JPutUjoeb-VSf-O_Svan74W5aPg@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.158.1443144375.28679.python-list@python.org> (permalink) |
On Thu, 24 Sep 2015 07:45:50 -0600, <paul.hermeneutic@gmail.com> declaimed
the following:
>>> I'm suprised. Why not just:
>>>
>>> list(str(results))
>>>
>>> In other words, is there something else the list constructor should do
>>> with a string other than convert it to a list?
>>>
>> The OP wanted the result to be a list of ints, not a list of strings.
>
>[int(x) for x in list(str(results))]
results is already a string, so why convert it to a string, and list()
is just splitting the string on each character.
[int(x) for x in results]
takes out all the intervening crud.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python, convert an integer into an index? Chris Roberts <thecjguy1@gmail.com> - 2015-09-22 14:43 -0700
Re: Python, convert an integer into an index? Laura Creighton <lac@openend.se> - 2015-09-23 00:21 +0200
Re: Python, convert an integer into an index? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-23 00:23 +0100
Re: Python, convert an integer into an index? MRAB <python@mrabarnett.plus.com> - 2015-09-23 00:27 +0100
Re: Python, convert an integer into an index? marco.nawijn@colosso.nl - 2015-09-22 23:55 -0700
Re: Python, convert an integer into an index? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-22 23:13 -0400
Re: Python, convert an integer into an index? Anssi Saari <as@sci.fi> - 2015-09-23 12:01 +0300
Re: Python, convert an integer into an index? MRAB <python@mrabarnett.plus.com> - 2015-09-24 14:30 +0100
Re: Python, convert an integer into an index? jmp <jeanmichel@sequans.com> - 2015-09-24 16:14 +0200
Re: Python, convert an integer into an index? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-24 21:26 -0400
Re: Python, convert an integer into an index? Denis McMahon <denismfmcmahon@gmail.com> - 2015-09-23 15:32 +0000
Re: Python, convert an integer into an index? Lorenzo Sutton <lorenzofsutton@gmail.com> - 2015-09-24 18:13 +0200
Re: Python, convert an integer into an index? Tim Daneliuk <tundra@bogus-city.tundraware.com> - 2015-09-23 10:55 -0500
csiph-web