Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78528
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'syntax': 0.04; 'parser': 0.07; 'see.': 0.07; 'parsing': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'expression,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'module': 0.19; 'split': 0.19; 'input': 0.22; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'mathematical': 0.24; 'math': 0.24; 'cc:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'wonder': 0.29; 'message- id:@mail.gmail.com': 0.30; 'clever': 0.31; 'operators': 0.31; 'class': 0.32; 'there.': 0.32; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'module.': 0.36; 'should': 0.36; 'so,': 0.37; 'starting': 0.37; 'planning': 0.38; 'pm,': 0.38; 'how': 0.40; 'solve': 0.60; 'you.': 0.62; "you'll": 0.62; 'such': 0.63; 'strategy': 0.64; 'more': 0.64; 'overall': 0.69; 'parser,': 0.84; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=r1iC5bGM5IlJvM56xKn7zlNVZ+bBjV2SPOEbKwsRDHE=; b=p66Bg86hU3V+fDNO46HEHDJLcnHPzMiPQrOQq7GimF513s58v3SRAKL7DQtuVrNO/W pidrqM1P4f6I+fmco/otHORHWdj+71bto4HzUNJ6vTWOxxY+CKW1/RD93pf6AFp+qyER cD2l8rE2/E8tXHJMXJev/9vaNbtLhRTvQ3Mjvp9oZLM3bWe4sebFNGY/frx9Ersd+JuQ CnBviMwPeZeJ2TcZ6TEJzO5EtGCgBeXw1lWKAOnxSNgCclc67CaiN/jPnVlR4x1LCUjx pVHkVyyB8qCpp0uF0c0jxjEAkcuMpRBFKcGq7r8fKYfUzEvVAViaGmooeopmDgu00k30 vUXg== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.92.129 with SMTP id t1mr62807199icm.59.1412152716052; Wed, 01 Oct 2014 01:38:36 -0700 (PDT) |
| In-Reply-To | <a2044e0b-4c79-4318-855e-16f4c86d4169@googlegroups.com> |
| References | <4a7f3e7a-ba4d-405e-a078-937bf861fcd8@googlegroups.com> <mailman.14496.1412111706.18130.python-list@python.org> <a2044e0b-4c79-4318-855e-16f4c86d4169@googlegroups.com> |
| Date | Wed, 1 Oct 2014 18:38:35 +1000 |
| Subject | Re: how to parse standard algebraic notation |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| 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.14509.1412152724.18130.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1412152724 news.xs4all.nl 2847 [2001:888:2000:d::a6]:57987 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:78528 |
Show key headers only | View raw
On Wed, Oct 1, 2014 at 5:01 PM, math math <mathematisch@gmail.com> wrote:
> What would be a good starting strategy for writing a program to take the derivative of a polynomial expression, such as this below?:
> "x**3 + x**2 + x + 1"
>
> I am a bit confused about my overall strategy. Should one be writing a parser class to split the input on operators and then on the double asterisks? Are there more clever ways? Or is this something one should solve using mathematical formulas instead of parsing the characters?
>
> I just wonder how a seasoned Pythonian would go about a problem like this without using a ready-made derivative function from some module.
Well, let's see. Are you planning to use exact Python syntax
everywhere? For instance, will you use asterisks for multiplication
("5*x**3 + 2*x**2 - 5*x + 1")? If so, you could make use of the
ast.parse() module to do some of the work for you. Otherwise, you'll
have to start by writing up a grammar: exactly what is and isn't
allowed? Then write a parser, and see how things go from there.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to parse standard algebraic notation math math <mathematisch@gmail.com> - 2014-09-30 13:53 -0700
Re: how to parse standard algebraic notation Gary Herron <gherron@digipen.edu> - 2014-09-30 14:05 -0700
Re: how to parse standard algebraic notation math math <mathematisch@gmail.com> - 2014-10-01 00:01 -0700
Re: how to parse standard algebraic notation Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-01 08:35 +0100
Re: how to parse standard algebraic notation Chris Angelico <rosuav@gmail.com> - 2014-10-01 18:38 +1000
Re: how to parse standard algebraic notation math math <mathematisch@gmail.com> - 2014-10-01 05:04 -0700
Re: how to parse standard algebraic notation Marco Buttu <marco.buttu@gmail.com> - 2014-10-01 14:22 +0200
Re: how to parse standard algebraic notation Marco Buttu <marco.buttu@gmail.com> - 2014-10-01 14:26 +0200
Re: how to parse standard algebraic notation Chris Angelico <rosuav@gmail.com> - 2014-10-01 10:20 +1000
Re: how to parse standard algebraic notation wxjmfauth@gmail.com - 2014-10-01 01:08 -0700
Re: how to parse standard algebraic notation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-02 02:45 +1000
Re: how to parse standard algebraic notation Chris Angelico <rosuav@gmail.com> - 2014-10-02 03:01 +1000
csiph-web