Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Let's call it an accidental feature. -- Larry Wall


devel / comp.lang.python / Re: Understanding the working mechanis of python unary arithmetic operators.

SubjectAuthor
* Re: Understanding the working mechanis of python unary arithmetic operators.Julio Di Egidio
+* Re: Understanding the working mechanis of python unary arithmetic operators.hongy...@gmail.com
|+- Re: Understanding the working mechanis of python unary arithmetic operators.Tony Oliver
|`* Re: Understanding the working mechanis of python unary arithmetic operators.Julio Di Egidio
| `- Re: Understanding the working mechanis of python unary arithmetic operators.hongy...@gmail.com
`* Re: Understanding the working mechanis of python unary arithmetic operators.hongy...@gmail.com
 +* Re: Understanding the working mechanis of python unary arithmetic operators.hongy...@gmail.com
 |`* Re: Understanding the working mechanis of python unary arithmetic operators.Julio Di Egidio
 | `* Re: Understanding the working mechanis of python unary arithmetic operators.hongy...@gmail.com
 |  `* Re: Understanding the working mechanis of python unary arithmetic operators.Julio Di Egidio
 |   `* Re: Understanding the working mechanis of python unary arithmetic operators.hongy...@gmail.com
 |    `- Re: Understanding the working mechanis of python unary arithmetic operators.hongy...@gmail.com
 +- Re: Understanding the working mechanis of python unary arithmeticChris Angelico
 +* Re: Understanding the working mechanis of python unary arithmeticdn
 |`- Re: Understanding the working mechanis of python unary arithmetic operators.Julio Di Egidio
 `- RE: Understanding the working mechanis of python unary arithmeticAvi Gross

1
Re: Understanding the working mechanis of python unary arithmetic operators.

<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19937&group=comp.lang.python#19937

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:44cc:: with SMTP id r195mr1708968qka.77.1633165181821;
Sat, 02 Oct 2021 01:59:41 -0700 (PDT)
X-Received: by 2002:a05:6214:122e:: with SMTP id p14mr12828824qvv.57.1633165181711;
Sat, 02 Oct 2021 01:59:41 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 2 Oct 2021 01:59:41 -0700 (PDT)
In-Reply-To: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.79; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.79
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: julio@diegidio.name (Julio Di Egidio)
Injection-Date: Sat, 02 Oct 2021 08:59:41 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 22
 by: Julio Di Egidio - Sat, 2 Oct 2021 08:59 UTC

On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> See the following testings:
>
> In [24]: a=3.1415926535897932384626433832795028841971
> In [27]: -a
> Out[27]: -3.141592653589793

You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
<https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>

> In [17]: ~-+1
> Out[17]: 0

<< The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
<https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>

> I'm very puzzled by these operators. Any hints will be highly appreciated.

Try and read the proverbial manual: that's truly a fundamental skill...

HTH,

Julio

Re: Understanding the working mechanis of python unary arithmetic operators.

<dade18c4-9480-4a6e-990a-b944bcc5b52an@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19938&group=comp.lang.python#19938

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:bf82:: with SMTP id p124mr2293377qkf.45.1633178907577; Sat, 02 Oct 2021 05:48:27 -0700 (PDT)
X-Received: by 2002:ac8:5a0f:: with SMTP id n15mr3304808qta.129.1633178907394; Sat, 02 Oct 2021 05:48:27 -0700 (PDT)
Path: rocksolid2!i2pn.org!aioe.org!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 2 Oct 2021 05:48:27 -0700 (PDT)
In-Reply-To: <ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=47.241.171.246; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 47.241.171.246
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com> <ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dade18c4-9480-4a6e-990a-b944bcc5b52an@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: hongyi.zhao@gmail.com (hongy...@gmail.com)
Injection-Date: Sat, 02 Oct 2021 12:48:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 61
 by: hongy...@gmail.com - Sat, 2 Oct 2021 12:48 UTC

On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > See the following testings:
> >
> > In [24]: a=3.1415926535897932384626433832795028841971
> > In [27]: -a
> > Out[27]: -3.141592653589793
> You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> > In [17]: ~-+1
> > Out[17]: 0
> << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>
> > I'm very puzzled by these operators. Any hints will be highly appreciated.
> Try and read the proverbial manual: that's truly a fundamental skill...

Thank you for your explanation. Then what about the following questions?:

1. Should `+' and `-' be classified as binary operators or unary operators? As we all know, `a + b', and `a - b' are the normal ways we do basic arithmetic operations.

2. See the following testings:

In [20]: bool(int(True))
Out[20]: True

In [21]: bool(~int(True))
Out[21]: True

In [22]: bool(~~int(True))
Out[22]: True

In [23]: bool(~~~int(True))
Out[23]: True

In [24]: bool(int(False))
Out[24]: False

In [25]: bool(~int(False))
Out[25]: True

In [26]: bool(~~int(False))
Out[26]: False

In [27]: bool(~~~int(False))
Out[27]: True

Why can’t/shouldn't we get something similar results for both `True' and `False' in the above testings?

HZ

Re: Understanding the working mechanis of python unary arithmetic operators.

<fb0ca407-e519-43f6-bb8d-9044b16d2389n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19940&group=comp.lang.python#19940

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ac8:111:: with SMTP id e17mr4394275qtg.34.1633191361651;
Sat, 02 Oct 2021 09:16:01 -0700 (PDT)
X-Received: by 2002:ac8:5a0f:: with SMTP id n15mr4275254qta.129.1633191361330;
Sat, 02 Oct 2021 09:16:01 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 2 Oct 2021 09:16:01 -0700 (PDT)
In-Reply-To: <dade18c4-9480-4a6e-990a-b944bcc5b52an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=62.249.217.89; posting-account=FHqkeAoAAACbOpBCHa7K6JTmToKlWNDp
NNTP-Posting-Host: 62.249.217.89
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <dade18c4-9480-4a6e-990a-b944bcc5b52an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fb0ca407-e519-43f6-bb8d-9044b16d2389n@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: guinness.tony@gmail.com (Tony Oliver)
Injection-Date: Sat, 02 Oct 2021 16:16:01 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 88
 by: Tony Oliver - Sat, 2 Oct 2021 16:16 UTC

On Saturday, 2 October 2021 at 13:48:39 UTC+1, hongy...@gmail.com wrote:
> On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > > See the following testings:
> > >
> > > In [24]: a=3.1415926535897932384626433832795028841971
> > > In [27]: -a
> > > Out[27]: -3.141592653589793
> > You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> > <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> > > In [17]: ~-+1
> > > Out[17]: 0
> > << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> > <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>
> > > I'm very puzzled by these operators. Any hints will be highly appreciated.
> > Try and read the proverbial manual: that's truly a fundamental skill...
> Thank you for your explanation. Then what about the following questions?:
>
> 1. Should `+' and `-' be classified as binary operators or unary operators?

Both. See sections 6.6 and 6.7 of the documentation at
https://docs.python.org/3/reference/expressions.html

> As we all know, `a + b', and `a - b' are the normal ways we do basic arithmetic operations.

Really? Don't you ever write something like "x = -y"?
Or do you habitually write "x = 0 - y" or "x = 0.0 - y"?

> 2. See the following testings:
>
> In [20]: bool(int(True))
int(True) -> 1
bool(1) -> True
> Out[20]: True
>
> In [21]: bool(~int(True))
int(True) -> 1
~1 -> -2
bool(-2) -> True
> Out[21]: True
>
> In [22]: bool(~~int(True))
int(True) -> 1
~1 -> -2 # these two operations
~(-2) -> 1 # cancel each other out
bool(1) -> True
> Out[22]: True
>
> In [23]: bool(~~~int(True))
Because two consecutive bit-inversions cancel each other out;
this is just a complicated re-statement of operation [21], above
> Out[23]: True
>
> In [24]: bool(int(False))
int(False) -> 0
bool(0) -> False
> Out[24]: False
>
> In [25]: bool(~int(False))
int(False) -> 0
~0 -> -1
bool(-1) -> True
> Out[25]: True
>
> In [26]: bool(~~int(False))
Again, two consecutive inversions cancel each other out
so this is just an over-complicated re-statement of [24]
> Out[26]: False
>
> In [27]: bool(~~~int(False))
Likewise, this is the equivalent of re-stating [25]
> Out[27]: True
>
> Why can’t/shouldn't we get something similar results for both `True' and `False' in the above testings?

Sorry, I can't parse that.

Re: Understanding the working mechanis of python unary arithmetic operators.

<5a02d664-8887-41f4-b5ab-558b78f67e25n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19942&group=comp.lang.python#19942

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:ba06:: with SMTP id k6mr3554836qkf.312.1633201511618;
Sat, 02 Oct 2021 12:05:11 -0700 (PDT)
X-Received: by 2002:ac8:505a:: with SMTP id h26mr5007292qtm.376.1633201511447;
Sat, 02 Oct 2021 12:05:11 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 2 Oct 2021 12:05:11 -0700 (PDT)
In-Reply-To: <dade18c4-9480-4a6e-990a-b944bcc5b52an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.79; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.79
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <dade18c4-9480-4a6e-990a-b944bcc5b52an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5a02d664-8887-41f4-b5ab-558b78f67e25n@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: julio@diegidio.name (Julio Di Egidio)
Injection-Date: Sat, 02 Oct 2021 19:05:11 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 88
 by: Julio Di Egidio - Sat, 2 Oct 2021 19:05 UTC

On Saturday, 2 October 2021 at 14:48:39 UTC+2, hongy...@gmail.com wrote:
> On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > > See the following testings:
> > >
> > > In [24]: a=3.1415926535897932384626433832795028841971
> > > In [27]: -a
> > > Out[27]: -3.141592653589793
> >
> > You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> > <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> >
> > > In [17]: ~-+1
> > > Out[17]: 0
> >
> > << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> > <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>
> >
> > > I'm very puzzled by these operators. Any hints will be highly appreciated.
> >
> > Try and read the proverbial manual: that's truly a fundamental skill...
>
> Thank you for your explanation. Then what about the following questions?:
>
> 1. Should `+' and `-' be classified as binary operators or unary operators?

"Symbol overloading": a+b is binary *addition*, +a is unary *identity* (or however you may like to call it). The meaning of a symbol or name depends on context.

> As we all know, `a + b', and `a - b' are the normal ways we do basic arithmetic operations.

Nonsense. You yourself wrote ~(-(+1)) above, just without parentheses.

> 2. See the following testings:

Read the bloody manual.

Given that:
int(True) = 1
int(False) = 0

and that:
bool(x) is True iff x <> 0

and that:
~~x = x for all x (integer)

These:
~1 = -(1+1) = -2
~~1 = ~-2 = -(-2+1) = 1
~~~1 = ~1 = -2
....
all evaluate to True.

And these:
~0 = -(0+1) = -1
~~0 = ~-1 = -(-1+1) = 0
~~~0 = ~0 = -1
....
evaluate to True and False alternatingly.

In short, ~1=-2 (and ~-2=1) and 1 and -2 both convert to True, while ~0=1 but 0 converts to False while 1 converts to True.

> Why can’t/shouldn't we get something similar results for both `True' and `False' in the above testings?

Because bitwise complement is not symmetric around 0. For comparison, try with negation instead.

But don't just guess, try and unpack those expressions while trying and reading the docs: which is a necessary skill in itself.

Good luck,

Julio

Re: Understanding the working mechanis of python unary arithmetic operators.

<337cac0c-bbd9-4b27-8d42-5590361e8a48n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19948&group=comp.lang.python#19948

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:9d82:: with SMTP id g124mr4893934qke.237.1633238177749;
Sat, 02 Oct 2021 22:16:17 -0700 (PDT)
X-Received: by 2002:a37:ad0:: with SMTP id 199mr4700585qkk.261.1633238177603;
Sat, 02 Oct 2021 22:16:17 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 2 Oct 2021 22:16:17 -0700 (PDT)
In-Reply-To: <5a02d664-8887-41f4-b5ab-558b78f67e25n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=54.180.135.214; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 54.180.135.214
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <dade18c4-9480-4a6e-990a-b944bcc5b52an@googlegroups.com>
<5a02d664-8887-41f4-b5ab-558b78f67e25n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <337cac0c-bbd9-4b27-8d42-5590361e8a48n@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: hongyi.zhao@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 03 Oct 2021 05:16:17 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: hongy...@gmail.com - Sun, 3 Oct 2021 05:16 UTC

On Sunday, October 3, 2021 at 3:05:23 AM UTC+8, ju...@diegidio.name wrote:
> On Saturday, 2 October 2021 at 14:48:39 UTC+2, hongy...@gmail.com wrote:
> > On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> > > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > > > See the following testings:
> > > >
> > > > In [24]: a=3.1415926535897932384626433832795028841971
> > > > In [27]: -a
> > > > Out[27]: -3.141592653589793
> > >
> > > You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> > > <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> > >
> > > > In [17]: ~-+1
> > > > Out[17]: 0
> > >
> > > << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> > > <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>
> > >
> > > > I'm very puzzled by these operators. Any hints will be highly appreciated.
> > >
> > > Try and read the proverbial manual: that's truly a fundamental skill....
> >
> > Thank you for your explanation. Then what about the following questions?:
> >
> > 1. Should `+' and `-' be classified as binary operators or unary operators?
> "Symbol overloading": a+b is binary *addition*, +a is unary *identity* (or however you may like to call it). The meaning of a symbol or name depends on context.

As I understand now, it can be used to identify/normalize the operand by the corresponding precision in the given context.

> > As we all know, `a + b', and `a - b' are the normal ways we do basic arithmetic operations.
> Nonsense. You yourself wrote ~(-(+1)) above, just without parentheses.

Thank you for pointing out my contradictory assertion.

> > 2. See the following testings:
> Read the bloody manual.
>
> Given that:
> int(True) = 1
> int(False) = 0
>
> and that:
> bool(x) is True iff x <> 0

In [8]: bool(None)
Out[8]: False

In [9]: bool('')
Out[9]: False

In [10]: bool(0)
Out[10]: False

So, bool(x) is True iff x <> 0 , None, and '', as shown here [1]:

In [3]: import numpy as np
In [11]: np.array([1, 0.5, 0, None, 'a', '', True, False], dtype=bool)
Out[11]: array([ True, True, False, False, True, False, True, False])
[1] https://riptutorial.com/numpy/example/21181/creating-a-boolean-array#example
> and that:
> ~~x = x for all x (integer)
>
> These:
> ~1 = -(1+1) = -2
> ~~1 = ~-2 = -(-2+1) = 1
> ~~~1 = ~1 = -2
> ...
> all evaluate to True.
>
> And these:
> ~0 = -(0+1) = -1
> ~~0 = ~-1 = -(-1+1) = 0
> ~~~0 = ~0 = -1
> ...
> evaluate to True and False alternatingly.
>
> In short, ~1=-2 (and ~-2=1) and 1 and -2 both convert to True, while ~0=1 but 0 converts to False while 1 converts to True.
> > Why can’t/shouldn't we get something similar results for both `True' and `False' in the above testings?
> Because bitwise complement is not symmetric around 0. For comparison, try with negation instead.

Thanks again. I see, as follows:

In [1]: ~1
Out[1]: -2

In [2]: ~-1
Out[2]: 0


> But don't just guess, try and unpack those expressions while trying and reading the docs: which is a necessary skill in itself.

Thank you for the advice that showed me the way to truth.

HZ

Re: Understanding the working mechanis of python unary arithmetic operators.

<0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19949&group=comp.lang.python#19949

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:44c8:: with SMTP id r191mr4964796qka.507.1633241885869;
Sat, 02 Oct 2021 23:18:05 -0700 (PDT)
X-Received: by 2002:ac8:4583:: with SMTP id l3mr6979100qtn.188.1633241885717;
Sat, 02 Oct 2021 23:18:05 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 2 Oct 2021 23:18:05 -0700 (PDT)
In-Reply-To: <ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=172.104.173.61; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 172.104.173.61
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com> <ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: hongyi.zhao@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 03 Oct 2021 06:18:05 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 24
 by: hongy...@gmail.com - Sun, 3 Oct 2021 06:18 UTC

On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > See the following testings:
> >
> > In [24]: a=3.1415926535897932384626433832795028841971
> > In [27]: -a
> > Out[27]: -3.141592653589793
> You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> > In [17]: ~-+1
> > Out[17]: 0
> << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>

A further inference based on the above description:

Let us consider this equation: -(x+1) = x, the solution is -0.5, which is not an integer. So we can safely come to a conclusion:

If bool(a) == True, \forall a \in integer, then ~bool(a) == False; and vice versa.

This is exactly the theoretical basis to filter some specific columns in pandas, just as the issue discussed here [1].

[1] https://github.com/pandas-dev/pandas/issues/43832#issue-1013375587

HZ

Re: Understanding the working mechanis of python unary arithmetic operators.

<8e5df6b9-e157-4dd3-ad92-9646774afcean@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19951&group=comp.lang.python#19951

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:622a:2c4:: with SMTP id a4mr7317711qtx.92.1633253086024;
Sun, 03 Oct 2021 02:24:46 -0700 (PDT)
X-Received: by 2002:ac8:611c:: with SMTP id a28mr7562247qtm.160.1633253085842;
Sun, 03 Oct 2021 02:24:45 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sun, 3 Oct 2021 02:24:45 -0700 (PDT)
In-Reply-To: <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=60.249.28.129; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 60.249.28.129
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8e5df6b9-e157-4dd3-ad92-9646774afcean@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: hongyi.zhao@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 03 Oct 2021 09:24:46 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 42
 by: hongy...@gmail.com - Sun, 3 Oct 2021 09:24 UTC

On Sunday, October 3, 2021 at 2:18:17 PM UTC+8, hongy...@gmail.com wrote:
> On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > > See the following testings:
> > >
> > > In [24]: a=3.1415926535897932384626433832795028841971
> > > In [27]: -a
> > > Out[27]: -3.141592653589793
> > You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> > <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> > > In [17]: ~-+1
> > > Out[17]: 0
> > << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> > <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>
> A further inference based on the above description:
>
> Let us consider this equation: -(x+1) = x, the solution is -0.5, which is not an integer. So we can safely come to a conclusion:
>
> If bool(a) == True, \forall a \in integer, then ~bool(a) == False; and vice versa.
>
> This is exactly the theoretical basis to filter some specific columns in pandas, just as the issue discussed here [1].

Sorry my not very precise description above. I should have wanted to express the fact that I observed below:

In [3]: import numpy as np
In [15]: ~np.array([True])
Out[15]: array([False])

In [16]: ~np.array([False])
Out[16]: array([ True])

But the normal `True' and `False' don't the good symmetric feature as shown above:

In [21]: bool(~True)
Out[21]: True

In [22]: bool(~False)
Out[22]: True


> [1] https://github.com/pandas-dev/pandas/issues/43832#issue-1013375587
>
> HZ

Re: Understanding the working mechanis of python unary arithmetic operators.

<ba2b19c9-64e6-441a-a8fa-d68fd70e5b9fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19952&group=comp.lang.python#19952

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:40e:: with SMTP id 14mr5479020qke.197.1633257052984;
Sun, 03 Oct 2021 03:30:52 -0700 (PDT)
X-Received: by 2002:ac8:705b:: with SMTP id y27mr7775567qtm.73.1633257052801;
Sun, 03 Oct 2021 03:30:52 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sun, 3 Oct 2021 03:30:52 -0700 (PDT)
In-Reply-To: <8e5df6b9-e157-4dd3-ad92-9646774afcean@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.79; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.79
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<8e5df6b9-e157-4dd3-ad92-9646774afcean@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba2b19c9-64e6-441a-a8fa-d68fd70e5b9fn@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: julio@diegidio.name (Julio Di Egidio)
Injection-Date: Sun, 03 Oct 2021 10:30:52 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 48
 by: Julio Di Egidio - Sun, 3 Oct 2021 10:30 UTC

On Sunday, 3 October 2021 at 11:24:58 UTC+2, hongy...@gmail.com wrote:
> On Sunday, October 3, 2021 at 2:18:17 PM UTC+8, hongy...@gmail.com wrote:
> > On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> > > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > > > See the following testings:
> > > >
> > > > In [24]: a=3.1415926535897932384626433832795028841971
> > > > In [27]: -a
> > > > Out[27]: -3.141592653589793
> > > You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> > > <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> > > > In [17]: ~-+1
> > > > Out[17]: 0
> > > << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> > > <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>
> > A further inference based on the above description:
> >
> > Let us consider this equation: -(x+1) = x, the solution is -0.5, which is not an integer. So we can safely come to a conclusion:
> >
> > If bool(a) == True, \forall a \in integer, then ~bool(a) == False; and vice versa.
> >
> > This is exactly the theoretical basis to filter some specific columns in pandas, just as the issue discussed here [1].
> Sorry my not very precise description above. I should have wanted to express the fact that I observed below:
> In [3]: import numpy as np
> In [15]: ~np.array([True])
> Out[15]: array([False])
>
> In [16]: ~np.array([False])
> Out[16]: array([ True])
>
> But the normal `True' and `False' don't the good symmetric feature as shown above:
>
> In [21]: bool(~True)
> Out[21]: True
>
> In [22]: bool(~False)
> Out[22]: True

You keep missing the point:

<< The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>

Then you can guess that numpy overrides it and gives you *logical* negation of boolean values, while on primitives you get the usual *arithmetic* behaviour, where bool(~False) implicitly is bool(~int(False)) = bool(~0) = bool(-1) = True.

Please take note: (typically!) ~ denotes a bitwise operation on integers, not logical negation on booleans.

HTH,

Julio

Re: Understanding the working mechanis of python unary arithmetic operators.

<ee542b8d-5b71-4a20-aa50-5bc309d7478an@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19955&group=comp.lang.python#19955

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:9b16:: with SMTP id d22mr5762697qke.22.1633263661635;
Sun, 03 Oct 2021 05:21:01 -0700 (PDT)
X-Received: by 2002:ac8:4583:: with SMTP id l3mr8110839qtn.188.1633263661498;
Sun, 03 Oct 2021 05:21:01 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sun, 3 Oct 2021 05:21:01 -0700 (PDT)
In-Reply-To: <ba2b19c9-64e6-441a-a8fa-d68fd70e5b9fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=139.162.59.26; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.162.59.26
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<8e5df6b9-e157-4dd3-ad92-9646774afcean@googlegroups.com> <ba2b19c9-64e6-441a-a8fa-d68fd70e5b9fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ee542b8d-5b71-4a20-aa50-5bc309d7478an@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: hongyi.zhao@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 03 Oct 2021 12:21:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 100
 by: hongy...@gmail.com - Sun, 3 Oct 2021 12:21 UTC

On Sunday, October 3, 2021 at 6:31:05 PM UTC+8, ju...@diegidio.name wrote:
> On Sunday, 3 October 2021 at 11:24:58 UTC+2, hongy...@gmail.com wrote:
> > On Sunday, October 3, 2021 at 2:18:17 PM UTC+8, hongy...@gmail.com wrote:
> > > On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> > > > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > > > > See the following testings:
> > > > >
> > > > > In [24]: a=3.1415926535897932384626433832795028841971
> > > > > In [27]: -a
> > > > > Out[27]: -3.141592653589793
> > > > You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> > > > <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> > > > > In [17]: ~-+1
> > > > > Out[17]: 0
> > > > << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> > > > <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>
> > > A further inference based on the above description:
> > >
> > > Let us consider this equation: -(x+1) = x, the solution is -0.5, which is not an integer. So we can safely come to a conclusion:
> > >
> > > If bool(a) == True, \forall a \in integer, then ~bool(a) == False; and vice versa.
> > >
> > > This is exactly the theoretical basis to filter some specific columns in pandas, just as the issue discussed here [1].
> > Sorry my not very precise description above. I should have wanted to express the fact that I observed below:
> > In [3]: import numpy as np
> > In [15]: ~np.array([True])
> > Out[15]: array([False])
> >
> > In [16]: ~np.array([False])
> > Out[16]: array([ True])
> >
> > But the normal `True' and `False' don't the good symmetric feature as shown above:
> >
> > In [21]: bool(~True)
> > Out[21]: True
> >
> > In [22]: bool(~False)
> > Out[22]: True
> You keep missing the point:
> << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> Then you can guess that numpy overrides it and gives you *logical* negation of boolean values,

I try to dig through the numpy source code to pinning point the overriding/monkey patching/decorating code snippets, as follows:

$ rg -A5 -uu 'def __invert__' .
../numpy/__init__.pyi
2022: def __invert__(self: NDArray[bool_]) -> NDArray[bool_]: ...
2023- @overload
2024: def __invert__(self: NDArray[_IntType]) -> NDArray[_IntType]: ...
2025- @overload
2026: def __invert__(self: NDArray[object_]) -> Any: ...
2027-
2028- @overload
2029- def __pos__(self: NDArray[_NumberType]) -> NDArray[_NumberType]: ...
2030- @overload
2031- def __pos__(self: NDArray[timedelta64]) -> NDArray[timedelta64]: ...
--
2885: def __invert__(self) -> bool_: ...
2886- __lshift__: _BoolBitOp[int8]
2887- __rlshift__: _BoolBitOp[int8]
2888- __rshift__: _BoolBitOp[int8]
2889- __rrshift__: _BoolBitOp[int8]
2890- __and__: _BoolBitOp[bool_]
--
2993: def __invert__(self: _IntType) -> _IntType: ...
2994- # Ensure that objects annotated as `integer` support bit-wise operations
2995- def __lshift__(self, other: _IntLike_co) -> integer: ...
2996- def __rlshift__(self, other: _IntLike_co) -> integer: ...
2997- def __rshift__(self, other: _IntLike_co) -> integer: ...
2998- def __rrshift__(self, other: _IntLike_co) -> integer: ...

../numpy/array_api/_array_object.py
510: def __invert__(self: Array, /) -> Array:
511- """
512- Performs the operation __invert__.
513- """
514- if self.dtype not in _integer_or_boolean_dtypes:
515- raise TypeError("Only integer or boolean dtypes are allowed in __invert__")

../numpy/lib/user_array.py
179: def __invert__(self):
180- return self._rc(invert(self.array))
181-
182- def _scalarfunc(self, func):
183- if self.ndim == 0:
184- return func(self[0])

../numpy/lib/mixins.pyi
62: def __invert__(self): ...

Which is corresponding to the overriding mentioned above by you?

> while on primitives you get the usual *arithmetic* behaviour, where bool(~False) implicitly is bool(~int(False)) = bool(~0) = bool(-1) = True.

Implicit cast happens here automatically.
> Please take note: (typically!) ~ denotes a bitwise operation on integers, not logical negation on booleans.

Thank you for stressing the point again.

HZ

Re: Understanding the working mechanis of python unary arithmetic operators.

<04aebfa3-e686-4fc8-ae4b-4472d35f0bf3n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19956&group=comp.lang.python#19956

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ac8:5ac7:: with SMTP id d7mr8295037qtd.382.1633264683067;
Sun, 03 Oct 2021 05:38:03 -0700 (PDT)
X-Received: by 2002:ac8:6b43:: with SMTP id x3mr8164333qts.190.1633264682919;
Sun, 03 Oct 2021 05:38:02 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sun, 3 Oct 2021 05:38:02 -0700 (PDT)
In-Reply-To: <ee542b8d-5b71-4a20-aa50-5bc309d7478an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.79; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.79
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<8e5df6b9-e157-4dd3-ad92-9646774afcean@googlegroups.com> <ba2b19c9-64e6-441a-a8fa-d68fd70e5b9fn@googlegroups.com>
<ee542b8d-5b71-4a20-aa50-5bc309d7478an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <04aebfa3-e686-4fc8-ae4b-4472d35f0bf3n@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: julio@diegidio.name (Julio Di Egidio)
Injection-Date: Sun, 03 Oct 2021 12:38:03 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 13
 by: Julio Di Egidio - Sun, 3 Oct 2021 12:38 UTC

On Sunday, 3 October 2021 at 14:21:13 UTC+2, hongy...@gmail.com wrote:
> On Sunday, October 3, 2021 at 6:31:05 PM UTC+8, ju...@diegidio.name wrote:

> > Then you can guess that numpy overrides it and gives you *logical* negation of boolean values,
>
> I try to dig through the numpy source code to pinning point the overriding/monkey patching/decorating code snippets, as follows:

And you keep missing the point: look up numpy's *documentation* for that, not any source code.

It rather seems you very much like the sound of your voice...

*Plonk*

Julio

Re: Understanding the working mechanis of python unary arithmetic operators.

<d96f3d65-a4af-4b7e-840c-db83eb45d9e1n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19957&group=comp.lang.python#19957

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a0c:816b:: with SMTP id 98mr17823985qvc.37.1633269302700;
Sun, 03 Oct 2021 06:55:02 -0700 (PDT)
X-Received: by 2002:a05:622a:164b:: with SMTP id y11mr8469297qtj.310.1633269302460;
Sun, 03 Oct 2021 06:55:02 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sun, 3 Oct 2021 06:55:02 -0700 (PDT)
In-Reply-To: <04aebfa3-e686-4fc8-ae4b-4472d35f0bf3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=47.241.176.240; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 47.241.176.240
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<8e5df6b9-e157-4dd3-ad92-9646774afcean@googlegroups.com> <ba2b19c9-64e6-441a-a8fa-d68fd70e5b9fn@googlegroups.com>
<ee542b8d-5b71-4a20-aa50-5bc309d7478an@googlegroups.com> <04aebfa3-e686-4fc8-ae4b-4472d35f0bf3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d96f3d65-a4af-4b7e-840c-db83eb45d9e1n@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: hongyi.zhao@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 03 Oct 2021 13:55:02 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 26
 by: hongy...@gmail.com - Sun, 3 Oct 2021 13:55 UTC

On Sunday, October 3, 2021 at 8:38:16 PM UTC+8, ju...@diegidio.name wrote:
> On Sunday, 3 October 2021 at 14:21:13 UTC+2, hongy...@gmail.com wrote:
> > On Sunday, October 3, 2021 at 6:31:05 PM UTC+8, ju...@diegidio.name wrote:
>
> > > Then you can guess that numpy overrides it and gives you *logical* negation of boolean values,
> >
> > I try to dig through the numpy source code to pinning point the overriding/monkey patching/decorating code snippets, as follows:
> And you keep missing the point: look up numpy's *documentation* for that, not any source code.

I find the relevant explanation here [1]:

numpy.invert
[...]
Compute bit-wise inversion, or bit-wise NOT, element-wise.

Computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ~.
[...]
The ~ operator can be used as a shorthand for np.invert on ndarrays.

x1 = np.array([True, False])

~x1
array([False, True])

[1] https://numpy.org/doc/stable/reference/generated/numpy.invert.html#numpy-invert

HZ

Re: Understanding the working mechanis of python unary arithmetic operators.

<1e02c882-3cc0-410e-b988-e5f12d338397n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19959&group=comp.lang.python#19959

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:ae83:: with SMTP id x125mr7879067qke.37.1633307085314;
Sun, 03 Oct 2021 17:24:45 -0700 (PDT)
X-Received: by 2002:a37:b981:: with SMTP id j123mr7658063qkf.445.1633307085136;
Sun, 03 Oct 2021 17:24:45 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sun, 3 Oct 2021 17:24:44 -0700 (PDT)
In-Reply-To: <d96f3d65-a4af-4b7e-840c-db83eb45d9e1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=172.105.220.185; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 172.105.220.185
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<8e5df6b9-e157-4dd3-ad92-9646774afcean@googlegroups.com> <ba2b19c9-64e6-441a-a8fa-d68fd70e5b9fn@googlegroups.com>
<ee542b8d-5b71-4a20-aa50-5bc309d7478an@googlegroups.com> <04aebfa3-e686-4fc8-ae4b-4472d35f0bf3n@googlegroups.com>
<d96f3d65-a4af-4b7e-840c-db83eb45d9e1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e02c882-3cc0-410e-b988-e5f12d338397n@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: hongyi.zhao@gmail.com (hongy...@gmail.com)
Injection-Date: Mon, 04 Oct 2021 00:24:45 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 33
 by: hongy...@gmail.com - Mon, 4 Oct 2021 00:24 UTC

On Sunday, October 3, 2021 at 9:55:15 PM UTC+8, hongy...@gmail.com wrote:
> On Sunday, October 3, 2021 at 8:38:16 PM UTC+8, ju...@diegidio.name wrote:
> > On Sunday, 3 October 2021 at 14:21:13 UTC+2, hongy...@gmail.com wrote:
> > > On Sunday, October 3, 2021 at 6:31:05 PM UTC+8, ju...@diegidio.name wrote:
> >
> > > > Then you can guess that numpy overrides it and gives you *logical* negation of boolean values,
> > >
> > > I try to dig through the numpy source code to pinning point the overriding/monkey patching/decorating code snippets, as follows:
> > And you keep missing the point: look up numpy's *documentation* for that, not any source code.
> I find the relevant explanation here [1]:
>
> numpy.invert
> [...]
> Compute bit-wise inversion, or bit-wise NOT, element-wise.
>
> Computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ~.
> [...]
> The ~ operator can be used as a shorthand for np.invert on ndarrays.
>
> x1 = np.array([True, False])
>
> ~x1
> array([False, True])
>
> [1] https://numpy.org/doc/stable/reference/generated/numpy.invert.html#numpy-invert

Or use the following commands in IPython:

import numpy as np
np.invert?
np.info(np.invert)

> HZ

Re: Understanding the working mechanis of python unary arithmetic operators.

<mailman.931.1633468214.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19979&group=comp.lang.python#19979

  copy link   Newsgroups: comp.lang.python
Path: rocksolid2!news.neodome.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Understanding the working mechanis of python unary arithmetic
operators.
Date: Wed, 6 Oct 2021 08:10:01 +1100
Lines: 28
Message-ID: <mailman.931.1633468214.4164.python-list@python.org>
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
<0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<CAPTjJmrQZk4_7ycwr8tqWfo8M8b7xH983S-Aj=B2F5Hgp4z6JA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 58RPsu4u+Wl37PM0TfGQDA28LFAWSLj0x9NBF72+ubEg==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=HNuQ0rB+;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.131
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.75; '*S*': 0.01; 'description:': 0.05;
'subject:python': 0.06; 'expression': 0.09; 'url:reference': 0.09;
'applies': 0.16; 'bits': 0.16; 'chrisa': 0.16; 'decimal': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'integer': 0.16; 'integer,': 0.16; 'subject:working': 0.16;
'wrote:': 0.16; 'october': 0.17; 'to:addr:python-list': 0.20;
'url:wiki': 0.23; 'skip:- 10': 0.25; 'objects': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'same': 0.34; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'following': 0.35;
'from:addr:gmail.com': 0.35; 'special': 0.37; 'received:209.85':
0.37; 'received:209': 0.39; 'evaluation': 0.39; 'wed,': 0.39;
'double': 0.40; 'above': 0.62; 'come': 0.62; 'email
addr:gmail.com': 0.63; 'simply': 0.63; 'let': 0.66; 'numbers':
0.67; 'heard': 0.67; 'exactly': 0.68; 'further': 0.69; 'skip:a
40': 0.70; 'url-ip:208.80.154/24': 0.70; 'url-ip:208.80/16': 0.70;
'url:wikipedia': 0.70; '2021': 0.71; 'url-ip:208/8': 0.71;
'significant': 0.78; 'integral': 0.84; 'saturday,': 0.84;
'false;': 0.91; 'safely': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=XzbybQSU1wIyQf8vc1LtAK+NX1/WicjbFHEiMF3+QqM=;
b=HNuQ0rB+vmNavhXpNBxNMSjEWXJTHle5CB6coiYIPmj/Mcm6FD7CIR9Vyh+7TDgFfs
09KswRY+M8WWJBTnrJLicTZAega5yawdtBahWfGiwPIvJOOShupVI+ELE5POLLKNwd7q
w5tMZ8/5KEVhbtTHrUI5e2zrZErK4/RE22US2+cblEJGg2FI5X4nM6s3cYzECRfwl8F8
DUZ6rVlyNlVV3vNqW+yALsFbezsezx2cGwF/BGdWLLu6DTsLPzpO/USgDPjbXyHKIlD/
NUfScmVH46etIuN2o5jHnsFCMs9Yoj63mDRPe5YtOn9NwNB++2SxWSjWf935xaxu7Q57
ugMg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=XzbybQSU1wIyQf8vc1LtAK+NX1/WicjbFHEiMF3+QqM=;
b=a+LBzS5wjvP1AGYQhtOR2i+kpeEHkA3Ds8ekY2K//l0wJmbcNFitdJBgUXExI2VCnd
YF12jnZQgKegCCy7FBkiDru71Q24H5F1JgmTu+TJujLCCZq/q/92YmM7BcV+MEVv3JYc
bulRrFkrcaiPSK/85iSoNfQ1qF25hRLgNiWGg7+eB5o0U4RubUCGjB6Gr69hRIn3RpRh
wUswfTuSjXDfvKHwrqePaXVBo+GUtzB0qx/cS+3b7X7stP43+prgnYRSqd+aPdolBZg4
kyPqfte5PUYBVaWlFxy6CoEXDTYpkJ7XFIdXQWA5TLBkJcB4uRtBCASUTUgrj1QLXpMa
ljAA==
X-Gm-Message-State: AOAM532kUryL/WjGE3N6188T2hpEmKiOGDQUucYw17E6n8X516kHBlW0
wdOFEjKgU+VKPeqXYiPNLx8L5JUgNBfBzl9mnKN9LYxW4gM=
X-Google-Smtp-Source: ABdhPJyZrsQNqs5s9epmjfGeOt07Nu/SD3DfDJudMdJpIdQabiSbtGpc4SMv/uQWaqMt3SGnQ3TUwXle8mZS5F5oqtM=
X-Received: by 2002:a5d:6288:: with SMTP id k8mr24863653wru.137.1633468212138;
Tue, 05 Oct 2021 14:10:12 -0700 (PDT)
In-Reply-To: <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <https://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>
X-Mailman-Original-Message-ID: <CAPTjJmrQZk4_7ycwr8tqWfo8M8b7xH983S-Aj=B2F5Hgp4z6JA@mail.gmail.com>
X-Mailman-Original-References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
<0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
 by: Chris Angelico - Tue, 5 Oct 2021 21:10 UTC

On Wed, Oct 6, 2021 at 7:52 AM hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
>
> On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
> > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:
> > > See the following testings:
> > >
> > > In [24]: a=3.1415926535897932384626433832795028841971
> > > In [27]: -a
> > > Out[27]: -3.141592653589793
> > You've never heard of floating-point? Double precision has 53 significant bits of mantissa, corresponding approximately to 16 decimal digits.
> > <https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64>
> > > In [17]: ~-+1
> > > Out[17]: 0
> > << The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method. >>
> > <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations>
>
> A further inference based on the above description:
>
> Let us consider this equation: -(x+1) = x, the solution is -0.5, which is not an integer. So we can safely come to a conclusion:
>
> If bool(a) == True, \forall a \in integer, then ~bool(a) == False; and vice versa.
>

If bool(a) is True, then ~bool(a) is exactly the same as writing
~True, and a has become irrelevant. That is simply how expression
evaluation works.

ChrisA

Re: Understanding the working mechanis of python unary arithmetic operators.

<mailman.933.1633475471.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19981&group=comp.lang.python#19981

  copy link   Newsgroups: comp.lang.python
Path: rocksolid2!news.neodome.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (dn)
Newsgroups: comp.lang.python
Subject: Re: Understanding the working mechanis of python unary arithmetic
operators.
Date: Wed, 6 Oct 2021 12:10:59 +1300
Organization: DWM
Lines: 135
Message-ID: <mailman.933.1633475471.4164.python-list@python.org>
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
<0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<CAPTjJmrQZk4_7ycwr8tqWfo8M8b7xH983S-Aj=B2F5Hgp4z6JA@mail.gmail.com>
<64070f5a-62b4-8368-248e-a9c49cc78f0d@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de 0jzW7vAHKH1x+R8LoznhagF63bKmx1ztGHXzRdHrNNkQ==
Return-Path: <PythonList@DancesWithMice.info>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=danceswithmice.info header.i=@danceswithmice.info
header.b=G619aCKd; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.011
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'looks': 0.02; "python's":
0.05; 'random': 0.05; 'thread': 0.05; 'subject:python': 0.06;
'achieved': 0.07; 'all!': 0.07; 'explanation': 0.07; '=dn': 0.09;
'angelico': 0.09; 'expression': 0.09;
'from:addr:danceswithmice.info': 0.09; 'from:addr:pythonlist':
0.09; 'fun,': 0.09; 'instances': 0.09; 'lazy': 0.09; 'much,':
0.09; 'operators': 0.09; 'url:reference': 0.09; '"add': 0.16;
'"add",': 0.16; '(because': 0.16; '1110': 0.16; '1111': 0.16;
'cases,': 0.16; 'instances,': 0.16; 'integer': 0.16; 'me?': 0.16;
'message-id:@DancesWithMice.info': 0.16; 'received:51.254': 0.16;
'received:51.254.211': 0.16; 'received:51.254.211.219': 0.16;
'received:cloud': 0.16; 'received:rangi.cloud': 0.16;
'subject:working': 0.16; 'thread.': 0.16; 'whilst': 0.16;
'wrote:': 0.16; 'problem': 0.16; 'october': 0.17; 'says': 0.17;
'probably': 0.17; "aren't": 0.19; 'to:addr:python-list': 0.20;
"i've": 0.22; 'bit.': 0.22; 'maybe': 0.22; 'code': 0.23; "i'd":
0.24; 'idea': 0.24; '(and': 0.25; 'seems': 0.26; 'binary': 0.26;
'intend': 0.26; 'object': 0.26; 'bit': 0.27; '>>>': 0.28; 'chris':
0.28; 'fact': 0.28; 'series': 0.28; 'thinking': 0.28; 'header
:User-Agent:1': 0.30; 'header:Organization:1': 0.31; 'think':
0.32; 'concept': 0.32; 'point,': 0.32; 'split': 0.32; 'but': 0.32;
"i'm": 0.33; 'there': 0.33; 'hold': 0.33; 'same': 0.34; "didn't":
0.34; 'header:In-Reply-To:1': 0.34; 'particularly': 0.35; 'words':
0.35; 'also,': 0.36; 'presented': 0.37; 'though': 0.37; 'way':
0.38; 'could': 0.38; 'means': 0.38; 'two': 0.39; 'changes': 0.39;
'single': 0.39; 'list': 0.39; 'use': 0.39; 'evaluation': 0.39;
'neither': 0.39; 'wed,': 0.39; 'both': 0.40; 'something': 0.40;
'should': 0.40; 'in,': 0.60; 'tell': 0.60; 'skip:o 10': 0.61;
'above': 0.62; 'mental': 0.62; 'here': 0.62; 'subject': 0.63;
'true': 0.63; 'email addr:gmail.com': 0.63; 'simply': 0.63;
'share': 0.63; 'complete': 0.64; 'becomes': 0.64; 'expressed':
0.64; 'number,': 0.64; 'received:51': 0.64; 'thus': 0.64;
'widely': 0.64; 'your': 0.64; 'look': 0.65; '100%': 0.66;
'received:userid': 0.66; 'earlier': 0.67; 'now,': 0.67; 'mind.':
0.67; 'choose': 0.67; 'exactly': 0.68; 'store,': 0.69; 'instead,':
0.70; '2021': 0.71; 'plus': 0.73; 'covered': 0.75;
'received:localhost.localdomain': 0.76; 'reply': 0.77; 'discover':
0.80; 'quickly': 0.80; 'received:localdomain': 0.81; 'happens':
0.84; '"2"': 0.84; 'ever,': 0.84; 'forgotten': 0.84;
'received:47': 0.84; 'saturday,': 0.84; 'sign,': 0.84; 'subject:
\n ': 0.84; 'talked': 0.84; 'that!': 0.84; 'this)': 0.84; 'thus,':
0.84; 'thus:': 0.84; 'question?': 0.91
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on vps517507.ovh.net
X-Spam-Level:
X-Spam-Status: No, score=-3.0 required=5.0 tests=ALL_TRUSTED,BAYES_00,
DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,NICE_REPLY_A autolearn=ham
autolearn_force=no version=3.4.0
DKIM-Filter: OpenDKIM Filter v2.11.0 mail.rangi.cloud 99E7424A1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1633475468;
bh=vaV3lMFzynCb4mjEaU70JwOkk3RnI9OFq7AVpU1I3x0=;
h=Subject:To:References:From:Date:In-Reply-To:From;
b=G619aCKdUgGUVOfNVD2nde2PsavufZkzrBVzh8ILUSAq/kUiGpoSZUyOKdpSBr6ne
+36SnqkikL1MLF88FCqra4T/62nLy2Sbukm6GhfYwYGhidOmJlgDimUphvJ0+8UKjK
lFsY7bSDaZKrbRj98jKQeT3jAnEUqSCHsYhVnND/9RzfBH/W64X3whc+64cuo6KQuk
i5G+Jqk63ILGvp1r4ECsRv+iUKWmme6KTm18n3x9vVd74PX2HHJncXUNE5ohh+Zolc
UPfBqRs2xhS+cUSICR+ngbWU2bEoAZoNT/WJ5002Mn2g0AZFMPWdA9dpVSn2QhJbej
fXO8VZWusBgMA==
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
In-Reply-To: <CAPTjJmrQZk4_7ycwr8tqWfo8M8b7xH983S-Aj=B2F5Hgp4z6JA@mail.gmail.com>
Content-Language: en-GB
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <https://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>
X-Mailman-Original-Message-ID: <64070f5a-62b4-8368-248e-a9c49cc78f0d@DancesWithMice.info>
X-Mailman-Original-References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
<0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<CAPTjJmrQZk4_7ycwr8tqWfo8M8b7xH983S-Aj=B2F5Hgp4z6JA@mail.gmail.com>
 by: dn - Tue, 5 Oct 2021 23:10 UTC

On 06/10/2021 10.10, Chris Angelico wrote:
> On Wed, Oct 6, 2021 at 7:52 AM hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
>>
>> On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:

This thread seems to have been very one-sided. Either I've forgotten
selective use of the DEL-key, or the above contributor has been
forgetting to reply to the list (or didn't intend contribution?) Please
share your knowledge with all!

>>> On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:

> If bool(a) is True, then ~bool(a) is exactly the same as writing
> ~True, and a has become irrelevant. That is simply how expression
> evaluation works.

@Chris and I presented at a recent PUG meeting on the subject of
'operators'.
(I was the 'warm-up act', @Chris the 'star'...)

I covered unary operators
(https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations)
- and very briefly, because that's proportional to their application 'in
the real world'. Negation is sometimes used, binary inversion very
occasionally, but the 'unary plus' almost never!

Thus:

>>> a = 3
>>> +a
3 >>> -a
-3

Why would one use the plus operator?

Particularly when it confuses some, ie if negation changes the sign,
won't the unary-plus?

>>> b = -3
>>> +b
-3
>>> -b
3

What has the unary-plus achieved in either/both of these cases? Not
much, but may not be doing something that was 'expected'!

The bitwise inversion (~) is also widely misunderstood (just like the
story of my life). It is not "bit inversion", as in, a single bit being
inverted:
(values here are expressed in base-2!)

~0 -> 1
~1 -> 0

Instead, it involves the inversion of every bit. Thus, if we are talking
about a nibble/nybble (because I'm too lazy to type more binary digits):

~0000 -> 1111
~0001 -> 1110

which accounts for the problem discussed earlier in the thread.

To make things work the way you seemed to imagine:

~1111 -> 0000 # and thus, is False
~0000 -> 1111 # and thus, is True

ie a bitwise inter-change that works binary ints and booleans.

Where some (other) thinking may have come-adrift from Python's model, is
the mixing of objects/types, eg the 'truthiness' of any integer other
than 0. Also, whilst coercion from one type to another may work
satisfactorily in one 'direction', it may not be so amenable in reverse.

Another bemusing (OP) point was the concept of "-+~1". I'd never, ever,
think of doing that! Hey, maybe that says something about me?

The term "unary operator" involves the word "one". Rather than
"operator", the "one" is the number of "operands". (yes, you know this)
However, having already talked about the infrequency with which
unary-operators are employed, the idea of nesting (is that the word?) a
series of unary-operators, almost blew my mind. Why? Please show an
example scenario...

Finally, there is the process of "over-loading" operators. Thus, "1 + 2"
translates to "add the value 2 to 1"; whereas "a" + "b" means
"concatenate" the two strings. In both cases, the result becomes a third
value. When we choose the correct terminology, the words for "+" are
different - as are the resultant processes!

We could also code "instance_a + instance_b". What does this mean?
Addition? Concatenation? Bitwise?

If I tell you that both are instances of MyClass, does that answer the
question?

The only way to work-out what craziness I hold in store, is to find
where MyClass is defined and look for the __add__() 'magic method'*. At
which point, you discover that the instance-attributes are split into
components, and the components merged together in a random sequence,
with today's date mixed-in for (no) good measure.

* or you could ask me
(although neither explanation will have a +impact on your mental health)

So, the fact that two object instances, eg an integer and a
floating-point number, both utilise the same operator-symbol, enables us
to draw analogies (and in this case, probably get it 100% correct), but
this does not imply a complete equivalence across-the-board
(particularly when crazy-people are let-loose with custom classes! Thus
"a" + "b" should not be pronounced "add", even though the operator looks
very much like the one we use to add two numbers!

For fun, and quickly now, what happens here:

2 + 2
2 + 2.0
2.0 + 2
2.0 + 2.0
"2" + "2"
2 + "2"
"2" + 2

(they're all 'the same', except the last two?three - aren't they???)

--
Regards,
=dn

RE: Understanding the working mechanis of python unary arithmetic operators.

<mailman.934.1633477379.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19982&group=comp.lang.python#19982

  copy link   Newsgroups: comp.lang.python
Path: rocksolid2!news.neodome.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigross@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: RE: Understanding the working mechanis of python unary arithmetic
operators.
Date: Tue, 5 Oct 2021 19:42:56 -0400
Lines: 176
Message-ID: <mailman.934.1633477379.4164.python-list@python.org>
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
<0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<CAPTjJmrQZk4_7ycwr8tqWfo8M8b7xH983S-Aj=B2F5Hgp4z6JA@mail.gmail.com>
<64070f5a-62b4-8368-248e-a9c49cc78f0d@DancesWithMice.info>
<00c801d7ba42$b9810fd0$2c832f70$@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de pbzpzcnt5fGeXnPmUqRpkAHAuU6WICWfJdD1hDVRMh8A==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=W+s337H3;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.010
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'looks': 0.02; "python's":
0.05; 'random': 0.05; 'thread': 0.05; 'subject:python': 0.06;
'achieved': 0.07; 'all!': 0.07; 'explanation': 0.07; '=dn': 0.09;
'angelico': 0.09; 'expression': 0.09; 'fun,': 0.09; 'instances':
0.09; 'lazy': 0.09; 'much,': 0.09; 'operators': 0.09; 'pre': 0.09;
'url:reference': 0.09; 'url:mailman': 0.15; '"add': 0.16;
'"add",': 0.16; '(because': 0.16; '1110': 0.16; '1111': 0.16;
'another.': 0.16; 'arithmetic': 0.16; 'cases,': 0.16;
'instances,': 0.16; 'integer': 0.16; 'me?': 0.16; 'received:(vzm
hermes smtp server)': 0.16; 'subject:working': 0.16; 'thread.':
0.16; 'whilst': 0.16; 'wrote:': 0.16; 'problem': 0.16; 'python':
0.16; 'october': 0.17; 'says': 0.17; 'probably': 0.17; "aren't":
0.19; 'to:addr:python-list': 0.20; 'language': 0.21; "i've": 0.22;
'bit.': 0.22; 'maybe': 0.22; 'code': 0.23; "i'd": 0.24; 'idea':
0.24; '(and': 0.25; 'skip:- 10': 0.25; 'url-ip:188.166.95.178/32':
0.25; 'url-ip:188.166.95/24': 0.25; 'examples': 0.25;
'url:listinfo': 0.25; 'url-ip:188.166/16': 0.25; 'seems': 0.26;
'binary': 0.26; 'intend': 0.26; 'object': 0.26; 'bit': 0.27;
'done': 0.28; '>>>': 0.28; 'chris': 0.28; 'fact': 0.28; 'series':
0.28; 'thinking': 0.28; 'url-ip:188/8': 0.31; 'think': 0.32;
'concept': 0.32; 'context': 0.32; 'point,': 0.32; 'python-list':
0.32; 'split': 0.32; 'but': 0.32; "i'm": 0.33; 'there': 0.33;
'hold': 0.33; 'same': 0.34; "didn't": 0.34; 'header:In-Reply-
To:1': 0.34; 'particularly': 0.35; 'words': 0.35; 'also,': 0.36;
'people': 0.36; 'presented': 0.37; 'though': 0.37; 'way': 0.38;
'could': 0.38; 'means': 0.38; 'two': 0.39; 'changes': 0.39;
'single': 0.39; 'list': 0.39; 'use': 0.39; 'evaluation': 0.39;
'neither': 0.39; 'wed,': 0.39; 'tell': 0.60; 'skip:o 10': 0.61;
'above': 0.62; 'from:': 0.62; 'to:': 0.62; 'mental': 0.62;
'point.': 0.62; 'here': 0.62; 'subject': 0.63; 'true': 0.63;
'email addr:gmail.com': 0.63; 'simply': 0.63; 'share': 0.63;
'complete': 0.64; 'becomes': 0.64; 'expressed': 0.64; 'number,':
0.64; 're:': 0.64; 'received:74.6.133': 0.64; 'thus': 0.64;
'widely': 0.64; 'your': 0.64; 'look': 0.65; '100%': 0.66;
'earlier': 0.67; 'now,': 0.67; 'mind.': 0.67; 'choose': 0.67;
'exactly': 0.68; 'operations': 0.68; 'store,': 0.69; 'instead,':
0.70; '2021': 0.71; 'plus': 0.73; 'covered': 0.75; 'reply': 0.77;
'sent:': 0.78; 'discover': 0.80; 'quickly': 0.80; 'happens': 0.84;
'"2"': 0.84; 'ever,': 0.84; 'forgotten': 0.84; 'saturday,': 0.84;
'sign,': 0.84; 'talked': 0.84; 'that!': 0.84; 'this)': 0.84;
'thus,': 0.84; 'thus:': 0.84; 'question?': 0.91; 'legal,': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1633477377; bh=XaScSnK8gCMW919tcFSNy3b75U1ilxnZgnhjLfS27VA=;
h=From:To:References:In-Reply-To:Subject:Date:From:Subject:Reply-To;
b=W+s337H3VyLHB3EpIRYtKlGZJknB80Xro/jidvvUYXg8sXWlQpIULc1WtEms9GElqS/tgEuOJ4gVp7DQbxdxdTBuP29+N1feAA01QkaE/zJJoWMl8XFMTfdumSyflU1T2QvV/WOAjefKW/yK/1C3+ctcFHqaVmaarEDuw8/qt1HUX+rARAmRZHu6JsMmZDX9vx4DKLdlATggc8VO3SOXMuJugtuVLJNr7LdYUvHeI/Cb1qQUwM68AfaYzbbs65Z8qHh6jY3BBm/n8TpxfLaspQJ62tp/CzAC0mh/JcDdmU4vy5xguMFspevl7Y2m0UT1qXWmvJIIgGz6tyLh4ivf9w==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1633477377; bh=a/BVMajb2DHvL23EsCJJWfHIvjlNUR35gu6C+1wAC7R=;
h=X-Sonic-MF:From:To:Subject:Date:From:Subject;
b=jWuM014B+xjr2s+2gUUwN49llBGyRNl/NS/KKSGmCXvBf/mw2zAZ/l9rityr1Zslu7Jlu2+qCmt8y0j8tDpsj7uXEBQ06H414m+RoWrCXq+qaT9jtAYF4I1yFnZ8TpGlqEwmeZs8xB39ftOk49yEzbef8spediVe3+BIjNkXxMMEKEK+GuOBGYWpxgssL+3dy1k50+NA/7QYwJBnJTKqlXYZ8QtznW83foxgY5k9nZDOT9gSjgZVBTa+RsVdVHZERNgsfSfyjL4c4WB/UQf2/Q0I5LDCBk94ax78/lU3ZomZGTru+7VFu4CPU8ScsVA5iEECgfbrqwgByi619HltDQ==
X-YMail-OSG: n.519wEVM1nzlMAfhzrxtBkrHoZkGCY5QjqDey9yOoe2czlakYnTvBQhMtrokI7
aVT7Xon3vu5xkNLPG34bcn3J65HE0Q.H9a.F4trLDIdjtJDsKeEDfMBFeepRVKi8oIPsLESlPR4U
GxmyRKsqkkLUSrol1qQeDFdSXKkPiieGm0rgoRp0BKM3Q7mFnN0E6kEfNqvS9OSNYyF3Qnlj85F0
uAZHsJJSE9m4EJ25rGNml4xpTrS2TWaJ0gQWXkrrFfg51P9NDEH5c3eq4orZ.qk8dMuMyq348_CO
qAAC4Q7VfrdcTFlcA_gT5L2OQa3Q5S.a_tFrA1a9AbyLCSXwych8R5SsVHkbyKIIdjHlTQTbQHsY
9TUGxPf.jwZxpazZEWj5gH7iuYoe8FGOmVgKqsgA1JqcXLh1TJ_QmRc0i3HiW8lmWCoTBLofdD6S
It969mhMLeE1WSgSSkvKqjgoYffgzwlDE5nmNjWqgMH_eGG5lDFlJ4BHD1ZQk1iUBqZFUm24Q98N
U.jK0wE5ujoAjIaHw1sGzTzxFpxuZtgOw1n170UenxAcmcWQ6WTPVPiwXNyoJUOy9wo4BpbMKF5k
p3ETfzCde16HyHP7c0TZzZkYTP5huSgfMJzDGbTWeQn7tpPeSC.CaETGy0W2NLPqAsHwhkIxf7DK
wGU5Oq0YQePCgbIq1GKz68z7GdSdpu72V80CkhqBKL5dwL8DlklnZq.YewVJ25S2je_2_Cw8rkxj
RdQ2BoBEya8bfNM5QMOL.T7vyK1u0dEUwy7Z7k78VMdGNSnujeMBZNiNClIg3pvOrQRTQnwZdcsu
fkT0Gqkk88srq5VU78eCvutawPODjvaKcNcKPplMI6RdrMmL2lGO4797aXKYwaFjsSXOUCen6ooq
RJdqZGv4TZPjNda4z20jOwligwh8WN63U3i0eDckLgmLbYQgnT2zkt7xjz5OBhtTmXBe6vL6K6dW
pfGOqwfeDmL2N6PK3Es7XgmKZp3T20z12PcguSVbY.nLMrlPbKat2KmOb.Sqvdx2.215cVA7Iea0
Y2HBUbC0yN6bpiLWkEaQ6dOm3vdJflSsWQH.Jq2VHaTTvjrn996GNTSbVfPEZmoOikA3OKZNsX9G
dXaZsasDkNYKi8xwEeWpRJkzd9G98ZqnQZozmtu8F2fTmBUVtwvji.6WU1rv_qxGOzBrL1JK8AXl
txwVikPnnSgNoPopQHLq0MnFZFWMqio5Me.q121wgC9UOyLJoPdrYRCHiuLXiaoTOMLM2pO33VBO
yaDxMDlCcyo1KkJiQBK4NH39mx57f7f3QEUZeqsYCVcKvj_cfk5.OCAOjMaaxOUbXRHtolscyn6C
gs_Nc9uOfDfKrJEVrlBcXos_KdjAN4_6ovSYFRnrQkMMm1Mo3zME6yElhdQjijZKMK7mkjfcTTtg
mS72mF94U8Lh7Oqc.FGlPlb2JVSyc6e4_dmNwhDIgX2i8zQ2L1GKjawURrKwGcoSZ1rqT_Ob_Qp5
SGkfndclx17EXgSQRboRbuWQVY_zPleNMV97.ezHTlKvffvIjTp3FLY7ORmiCFXU0GUy_RqimnZ.
M_emmIvI_lswjACPN2J_kaNa50tqbcFSLv23FZx3F5jYGHbMwyfKNqfHjJ3mSSzBMI7uw7cQt.fY
gmXqif5ERCQbgWXqiMWtFh1Qha6VxAB5xMnbQDlqbYOtIKeTDpJVSRYZtMKzUpTP_jp.xxTiS9xY
Umgl2jyToXEdNbFyrRE7hn1QPcE..5wsLsn01X.t04Tz3yYRjDPv777KFG0KhUfjk79WVVwcO_l7
tZMrL5UfDwCjmHbefCgyhpY92gg85b1LNZEeFX2QukE9ImwS3nGxEcPl3AivMyJfLKdLGBCgnUBr
ZFyY0aH0PLpg6yRVKc.5qcj3IDJIhD3PvUxUEvBx8KzQu7Qad08ob.WMY8aMlzhQwvXL7omkKypt
1lKjvE.W3FMS.jXo9e_WzSyQsQGGd8emKfsAW.7Sq8Mevxf_LX47VFDX6KjRpBY58H3K1QpGKiSr
8W_u4qbS8f9ub2iwX8x5jmG6YvCjui76T4ZssuyNjmN3AfyPKD3KF0szSNqN3.AElHZ57qDgPhh9
uWjXAtiMzO98exv3S_QnyRDOS4Wg5OCTQX2T8DrnmqjkUmCHM1LpeXPI0GTkgmsnUHEuOQQq9ScV
NAVwS5eu7PhWkGYCsUxga4qKH49Lf4frD8c4E3lHLebnv0TyIbthw7cBwutmDPst0NVQZnkq8MQq
r59cn4xvH9DHEOcDuHn2JhspXh2yMDGrIzpxq2WGYgUe7Jq3upWaabq8NCAA-
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <64070f5a-62b4-8368-248e-a9c49cc78f0d@DancesWithMice.info>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQKXyAYOSH2PO4UKxJKJpJnuQE0enAHlGgXAAonNBGABktc28gJzI6z6qgFJrBA=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <https://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>
X-Mailman-Original-Message-ID: <00c801d7ba42$b9810fd0$2c832f70$@verizon.net>
X-Mailman-Original-References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com>
<0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<CAPTjJmrQZk4_7ycwr8tqWfo8M8b7xH983S-Aj=B2F5Hgp4z6JA@mail.gmail.com>
<64070f5a-62b4-8368-248e-a9c49cc78f0d@DancesWithMice.info>
 by: Avi Gross - Tue, 5 Oct 2021 23:42 UTC

Dave,

Just one point.

many things are allowed by a language even if normal people would NOT have
any reason to do it NOR should use it.

Although when used in one context + and - can be considered unary operators,
the evaluation may result in successive unary operations being done one
after another. Here are examples I just typed:

+1
1 +++++1
1 +-+-+-1
-1
---1
-1
--1
1

Luckily since Python has no ++ or -- pre or post operators, these are legal,
albeit a tad weird.

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net@python.org> On
Behalf Of dn via Python-list
Sent: Tuesday, October 5, 2021 7:11 PM
To: python-list@python.org
Subject: Re: Understanding the working mechanis of python unary arithmetic
operators.

On 06/10/2021 10.10, Chris Angelico wrote:
> On Wed, Oct 6, 2021 at 7:52 AM hongy...@gmail.com <hongyi.zhao@gmail.com>
wrote:
>>
>> On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name
wrote:

This thread seems to have been very one-sided. Either I've forgotten
selective use of the DEL-key, or the above contributor has been forgetting
to reply to the list (or didn't intend contribution?) Please share your
knowledge with all!

>>> On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote:

> If bool(a) is True, then ~bool(a) is exactly the same as writing
> ~True, and a has become irrelevant. That is simply how expression
> evaluation works.

@Chris and I presented at a recent PUG meeting on the subject of
'operators'.
(I was the 'warm-up act', @Chris the 'star'...)

I covered unary operators
(https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-b
itwise-operations)
- and very briefly, because that's proportional to their application 'in the
real world'. Negation is sometimes used, binary inversion very occasionally,
but the 'unary plus' almost never!

Thus:

>>> a = 3
>>> +a
3 >>> -a
-3

Why would one use the plus operator?

Particularly when it confuses some, ie if negation changes the sign, won't
the unary-plus?

>>> b = -3
>>> +b
-3
>>> -b
3

What has the unary-plus achieved in either/both of these cases? Not much,
but may not be doing something that was 'expected'!

The bitwise inversion (~) is also widely misunderstood (just like the story
of my life). It is not "bit inversion", as in, a single bit being
inverted:
(values here are expressed in base-2!)

~0 -> 1
~1 -> 0

Instead, it involves the inversion of every bit. Thus, if we are talking
about a nibble/nybble (because I'm too lazy to type more binary digits):

~0000 -> 1111
~0001 -> 1110

which accounts for the problem discussed earlier in the thread.

To make things work the way you seemed to imagine:

~1111 -> 0000 # and thus, is False
~0000 -> 1111 # and thus, is True

ie a bitwise inter-change that works binary ints and booleans.

Where some (other) thinking may have come-adrift from Python's model, is the
mixing of objects/types, eg the 'truthiness' of any integer other than 0.
Also, whilst coercion from one type to another may work satisfactorily in
one 'direction', it may not be so amenable in reverse.

Another bemusing (OP) point was the concept of "-+~1". I'd never, ever,
think of doing that! Hey, maybe that says something about me?

The term "unary operator" involves the word "one". Rather than "operator",
the "one" is the number of "operands". (yes, you know this) However, having
already talked about the infrequency with which unary-operators are
employed, the idea of nesting (is that the word?) a series of
unary-operators, almost blew my mind. Why? Please show an example
scenario...

Finally, there is the process of "over-loading" operators. Thus, "1 + 2"
translates to "add the value 2 to 1"; whereas "a" + "b" means "concatenate"
the two strings. In both cases, the result becomes a third value. When we
choose the correct terminology, the words for "+" are different - as are the
resultant processes!

We could also code "instance_a + instance_b". What does this mean?
Addition? Concatenation? Bitwise?

If I tell you that both are instances of MyClass, does that answer the
question?

The only way to work-out what craziness I hold in store, is to find where
MyClass is defined and look for the __add__() 'magic method'*. At which
point, you discover that the instance-attributes are split into components,
and the components merged together in a random sequence, with today's date
mixed-in for (no) good measure.

* or you could ask me
(although neither explanation will have a +impact on your mental health)

So, the fact that two object instances, eg an integer and a floating-point
number, both utilise the same operator-symbol, enables us to draw analogies
(and in this case, probably get it 100% correct), but this does not imply a
complete equivalence across-the-board (particularly when crazy-people are
let-loose with custom classes! Thus "a" + "b" should not be pronounced
"add", even though the operator looks very much like the one we use to add
two numbers!

For fun, and quickly now, what happens here:

2 + 2
2 + 2.0
2.0 + 2
2.0 + 2.0
"2" + "2"
2 + "2"
"2" + 2

(they're all 'the same', except the last two?three - aren't they???)

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list

Re: Understanding the working mechanis of python unary arithmetic operators.

<e2d8d628-eb2f-48dd-afa3-67edb1e9acebn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19984&group=comp.lang.python#19984

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:9586:: with SMTP id x128mr18908895qkd.49.1633502041686;
Tue, 05 Oct 2021 23:34:01 -0700 (PDT)
X-Received: by 2002:a37:dc6:: with SMTP id 189mr253876qkn.349.1633502041544;
Tue, 05 Oct 2021 23:34:01 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Tue, 5 Oct 2021 23:34:01 -0700 (PDT)
In-Reply-To: <mailman.933.1633475471.4164.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.100.49; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.100.49
References: <4c8c0070-6889-4824-a4c3-a4bced7daa48n@googlegroups.com>
<ecbeb7d3-e8d3-4b84-ac5a-73fd8e2c1b3bn@googlegroups.com> <0910a4c5-bf29-4101-8de9-2315682d98fan@googlegroups.com>
<64070f5a-62b4-8368-248e-a9c49cc78f0d@DancesWithMice.info>
<CAPTjJmrQZk4_7ycwr8tqWfo8M8b7xH983S-Aj=B2F5Hgp4z6JA@mail.gmail.com> <mailman.933.1633475471.4164.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e2d8d628-eb2f-48dd-afa3-67edb1e9acebn@googlegroups.com>
Subject: Re: Understanding the working mechanis of python unary arithmetic operators.
From: julio@diegidio.name (Julio Di Egidio)
Injection-Date: Wed, 06 Oct 2021 06:34:01 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 29
 by: Julio Di Egidio - Wed, 6 Oct 2021 06:34 UTC

On Wednesday, 6 October 2021 at 01:11:24 UTC+2, dn wrote:
> On 06/10/2021 10.10, Chris Angelico wrote:
> > On Wed, Oct 6, 2021 at 7:52 AM hongy...@gmail.com <hongy...@gmail.com> wrote:
> >>
> >> On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote:
>
> This thread seems to have been very one-sided. Either I've forgotten
> selective use of the DEL-key, or the above contributor has been
> forgetting to reply to the list (or didn't intend contribution?) Please
> share your knowledge with all!

Are talking to me?? I just post to this shithole via Google Groups...

Anyway the regulars here routinely post over anything I post, ignore any explanations I carefully give, and contradict any advice I propose as fundamental... with their half cooked, ignorant and incompetent pub-level bullshit and then frauds. Because that's the sorry state of an entire industry and not only: the fucking nazi shithole that it's the only thing you seem fond of producing..

Indeed, who gives a shit about unary vs binary!! That is pre-pre-101 and of course it's gonna be a 100 posts thread with strong opinions around here. Fucking retarded cunts, the shithole is yours every day...

*Plonk*

Julio


devel / comp.lang.python / Re: Understanding the working mechanis of python unary arithmetic operators.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor