Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83580
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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; 'element': 0.07; 'float': 0.07; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'trailing': 0.09; 'jan': 0.12; 'comma': 0.16; 'confuse': 0.16; 'lambda': 0.16; 'optional': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'unnecessary.': 0.16; 'followed': 0.16; 'wrote:': 0.18; 'first.': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'performing': 0.26; 'header:X -Complaints-To:1': 0.27; 'character': 0.29; "skip:' 10": 0.31; '>>>>': 0.31; 'quotes': 0.31; 'subject:numbers': 0.31; 'supposed': 0.32; 'guess': 0.33; 'subject:from': 0.34; 'subject:with': 0.35; 'computing': 0.35; 'but': 0.35; 'list': 0.37; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'space': 0.40; 'sum': 0.64; 'thomas': 0.65; '2015': 0.84; 'joel': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: extracting numbers with decimal places from a string |
| Date | Mon, 12 Jan 2015 01:09:21 +0100 |
| Organization | None |
| References | <7240a574-dfd7-46c3-80eb-0657b41894bb@googlegroups.com> <mailman.17591.1421006803.18130.python-list@python.org> <3bfeea22-cded-4363-92fa-6f1b33ddae16@googlegroups.com> <mailman.17595.1421012580.18130.python-list@python.org> <8077448.xvuXrbCisO@PointedEars.de> <mailman.17599.1421016900.18130.python-list@python.org> <2182977.fJl0o3iPdP@PointedEars.de> <mailman.17600.1421019325.18130.python-list@python.org> <1786463.stBbe1naGD@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Gmane-NNTP-Posting-Host | p57bdb9c4.dip0.t-ipconnect.de |
| User-Agent | KNode/4.13.3 |
| 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.17603.1421021375.18130.python-list@python.org> (permalink) |
| Lines | 32 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1421021375 news.xs4all.nl 2832 [2001:888:2000:d::a6]:40100 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:83580 |
Show key headers only | View raw
Thomas 'PointedEars' Lahn wrote:
> Joel Goldstick wrote:
>
>> On Sun, Jan 11, 2015 at 6:12 PM, Thomas 'PointedEars' Lahn
>> <PointedEars@web.de> wrote:
>>> Joel Goldstick wrote:
>>>> Am I missing something.
>>> ^
>>> […]
>>> You are missing a leading space character because in the string the
>>> comma was followed by one.
>>
>> I see that now. Performing float on each element of the list will
>> take care of that, or I guess .strip() on each first.
>
> As I showed, .strip() is unnecessary. But float() is always necessary for
> computing the sum and suffices indeed together with s.split() if s is just
> a comma-separated list of numeric strings with optional whitespace leading
> and trailing the comma:
>
> print(sum(map(lambda x: float(x), s.split(',')))
>
> Please trim your quotes to the relevant minimum.
Hm, can you explain what this
lambda x: float(x)
is supposed to achieve? I mean other than to confuse a newbie...
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
extracting numbers with decimal places from a string Store Makhzan <store0a@gmail.com> - 2015-01-11 11:31 -0800
Re: extracting numbers with decimal places from a string Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-11 15:06 -0500
Re: extracting numbers with decimal places from a string Store Makhzan <store0a@gmail.com> - 2015-01-11 12:26 -0800
Re: extracting numbers with decimal places from a string Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-11 16:42 -0500
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-11 23:20 +0100
Re: extracting numbers with decimal places from a string Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-11 17:54 -0500
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 00:12 +0100
Re: extracting numbers with decimal places from a string Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-11 18:35 -0500
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 00:46 +0100
Re: extracting numbers with decimal places from a string Peter Otten <__peter__@web.de> - 2015-01-12 01:09 +0100
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 01:45 +0100
Re: extracting numbers with decimal places from a string Chris Angelico <rosuav@gmail.com> - 2015-01-12 11:17 +1100
Re: extracting numbers with decimal places from a string Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-12 11:45 +1100
Re: extracting numbers with decimal places from a string Grant Edwards <invalid@invalid.invalid> - 2015-01-11 23:06 +0000
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 00:07 +0100
Re: extracting numbers with decimal places from a string Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-12 00:04 +0000
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 02:00 +0100
Re: extracting numbers with decimal places from a string MRAB <python@mrabarnett.plus.com> - 2015-01-12 00:59 +0000
Re: extracting numbers with decimal places from a string Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-12 12:13 +1100
csiph-web