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


Groups > comp.lang.python > #56599

Re: I am never going to complain about Python again

From Neil Cerutti <neilc@norwich.edu>
Newsgroups comp.lang.python
Subject Re: I am never going to complain about Python again
Date 2013-10-10 18:49 +0000
Organization Norwich University
Message-ID <bbob64F12j4U1@mid.individual.net> (permalink)
References (2 earlier) <bbo0omFa53vU1@mid.individual.net> <l36ipg$kjt$1@dont-email.me> <mailman.951.1381421409.18130.python-list@python.org> <bbo7j0Fbp3qU1@mid.individual.net> <mailman.955.1381430188.18130.python-list@python.org>

Show all headers | View raw


On 2013-10-10, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Thu, Oct 10, 2013 at 11:48 AM, Neil Cerutti <neilc@norwich.edu> wrote:
>> Woah. I thought I was going by what the docs say:
>>
>>   Python fully supports mixed arithmetic: when a binary
>>   arithmetic operator has operands of different numeric types,
>>   the operand with the ?narrower? type is widened to that of the
>>   other, where integer is narrower than floating point, which is
>>   narrower than complex. Comparisons between numbers of mixed
>>   type use the same rule. [2] The constructors int(), float(),
>>   and complex() can be used to produce numbers of a specific
>>   type.
>>
>> [...]
>>
>>   [2] Not for complex numbers. Instead convert to floats using
>>      abs() if appropriate.
>>
>> I guess the "if appropriate" part eluded my eye. When *is* it
>> appropriate? Apparently not during an equal test.
>
> If you click on the footnote, it takes you to:
>
> [2]As a consequence, the list [1, 2] is considered equal to [1.0,
> 2.0], and similarly for tuples.
>
> The text that you have mistakenly identified as the footnote is
> actually part of the key to the "Notes" column of the numeric
> operations table, where it is referred to by the "x % y" and
> "divmod(x, y)" operations.  Specifically, it warns of this error:
>
>>>> 3j % 2j
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: can't mod complex numbers.

Doh!

Thanks, for that, and for the corrections. I could have avoided
all this by testing it correctly in the REPL, too.

I'll click on those footnotes instead of scanning to them from
now on.

-- 
Neil Cerutti

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


Thread

I am never going to complain about Python again Steven D'Aprano <steve@pearwood.info> - 2013-10-10 04:36 +0000
  Re: I am never going to complain about Python again Chris Angelico <rosuav@gmail.com> - 2013-10-10 15:50 +1100
  Re: I am never going to complain about Python again Chris Rebert <clp2@rebertia.com> - 2013-10-09 22:26 -0700
  Re: I am never going to complain about Python again Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-10 06:39 +0100
  Re: I am never going to complain about Python again Christian Gollwitzer <auriocus@gmx.de> - 2013-10-10 08:41 +0200
  Re: I am never going to complain about Python again "Frank Millman" <frank@chagford.com> - 2013-10-10 10:23 +0200
  Re: I am never going to complain about Python again MRAB <python@mrabarnett.plus.com> - 2013-10-10 12:10 +0100
  Re: I am never going to complain about Python again Tim Chase <python.list@tim.thechases.com> - 2013-10-10 06:43 -0500
  Re: I am never going to complain about Python again "Frank Millman" <frank@chagford.com> - 2013-10-10 13:44 +0200
  Re: I am never going to complain about Python again Roy Smith <roy@panix.com> - 2013-10-10 09:09 -0400
    Re: I am never going to complain about Python again Neil Cerutti <neilc@norwich.edu> - 2013-10-10 15:51 +0000
      Re: I am never going to complain about Python again Rotwang <sg552@hotmail.co.uk> - 2013-10-10 16:57 +0100
        Re: I am never going to complain about Python again MRAB <python@mrabarnett.plus.com> - 2013-10-10 17:10 +0100
          Re: I am never going to complain about Python again Neil Cerutti <neilc@norwich.edu> - 2013-10-10 17:48 +0000
            Re: I am never going to complain about Python again Ian Kelly <ian.g.kelly@gmail.com> - 2013-10-10 12:35 -0600
              Re: I am never going to complain about Python again Neil Cerutti <neilc@norwich.edu> - 2013-10-10 18:49 +0000
            Re: I am never going to complain about Python again Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-10 20:47 +0100
              Re: I am never going to complain about Python again Neil Cerutti <neilc@norwich.edu> - 2013-10-10 19:54 +0000
            Re: I am never going to complain about Python again Cameron Simpson <cs@zip.com.au> - 2013-10-11 08:52 +1100
            Re: I am never going to complain about Python again Roy Smith <roy@panix.com> - 2013-10-10 20:07 -0400
              Is this the room for an argument? John Ladasky <john_ladasky@sbcglobal.net> - 2013-10-10 21:26 -0700
                Re: Is this the room for an argument? Roy Smith <roy@panix.com> - 2013-10-11 09:49 -0400
            Re: I am never going to complain about Python again Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-11 02:23 +0000
              Re: I am never going to complain about Python again Neil Cerutti <neilc@norwich.edu> - 2013-10-11 12:31 +0000
    Re: I am never going to complain about Python again Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-10 20:09 -0400
    Re: I am never going to complain about Python again Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-11 02:08 +0000
      Re: I am never going to complain about Python again Joshua Landau <joshua@landau.ws> - 2013-10-11 09:17 +0100
        Re: I am never going to complain about Python again Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-11 09:11 +0000
          Re: I am never going to complain about Python again Chris Angelico <rosuav@gmail.com> - 2013-10-11 20:52 +1100
          Re: I am never going to complain about Python again Joshua Landau <joshua@landau.ws> - 2013-10-11 17:56 +0100

csiph-web