Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20279

Re: Numeric root-finding in Python

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Numeric root-finding in Python
Date 2012-02-12 11:47 -0500
References <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> <2276591.XVerqeASP3@mach-114-20>
Newsgroups comp.lang.python
Message-ID <mailman.5731.1329065705.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, 12 Feb 2012 10:20:17 -0500, inq1ltd <inq1ltd@inqvista.com>
wrote:

>
>
>I don't know the first thing about this math problem however,
>
>if I were to code this I might try ;
>
>   except ZeroDivisionError:
>         assert w = -1

	Uhm, that's invalid syntax, to my knowledge... Python doesn't allow
assignment (=) as an in-line operation.

>
>rather than;
>
>   except ZeroDivisionError:
>         assert w == -1
>
	This, OTOH, is a comparison operation...

	For small integers, using

		assert w is -1

might be an alternative, but it IS relying on the interpreter
implementation.

>>> w = 0
>>> assert w = -1
Traceback (  File "<interactive input>", line 1
    assert w = -1
             ^
SyntaxError: invalid syntax
>>> assert w == -1
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AssertionError
>>> assert w is -1
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AssertionError
>>> w = -1
>>> assert w == -1
>>> assert w is -1
>>> 
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Numeric root-finding in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-12 06:41 +0000
  Re: Numeric root-finding in Python Eelco <hoogendoorn.eelco@gmail.com> - 2012-02-12 02:10 -0800
    Re: Numeric root-finding in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-02-12 13:39 +0000
    Re: Numeric root-finding in Python Terry Reedy <tjreedy@udel.edu> - 2012-02-12 16:19 -0500
  Re: Numeric root-finding in Python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-12 05:13 -0800
  Re: Numeric root-finding in Python Robert Kern <robert.kern@gmail.com> - 2012-02-12 13:52 +0000
    Re: Numeric root-finding in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-12 22:53 +0000
  Re: Numeric root-finding in Python inq1ltd <inq1ltd@inqvista.com> - 2012-02-12 10:20 -0500
    Re: Numeric root-finding in Python David Monaghan <monaghand.david@gmail.com> - 2012-02-21 01:33 +0000
      Re: Numeric root-finding in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-02-21 02:21 +0000
  Re: Numeric root-finding in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-02-12 11:47 -0500
  Re: Numeric root-finding in Python Dave Angel <d@davea.name> - 2012-02-12 12:00 -0500
  Re: Numeric root-finding in Python Mark Dickinson <mdickinson@enthought.com> - 2012-02-12 12:18 -0800
    Re: Numeric root-finding in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-12 23:05 +0000
      Re: Numeric root-finding in Python Dave Angel <d@davea.name> - 2012-02-12 18:52 -0500

csiph-web