[New-bugs-announce] [issue36524] identity operator

Rocco Santoro report at bugs.python.org
Thu Apr 4 08:28:43 EDT 2019


New submission from Rocco Santoro <rojorougered at hotmail.com>:

Hi all

Why the identity operator and '=='  are both applied to the type (see above)? Is it not convenient to distinguish them? I mean the identity operator  applied to the type and '==' applied to the outcome.
Thanks for the attention
Best regards
Rocco Santoro

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import math
>>> x = math.log(10000000)
>>> y = math.log(10)
>>> print(x/y) == x/y
7.0
False
>>> print(math.log(10000000)/math.log(10)) == math.log(10000000)/math.log(10)
7.0
False
>>> x = math.sin(32)
>>> y = math.cos(41)
>>> print(y/x) == y/x
-1.7905177807148493
False
>>> x = math.pi
>>> y = math.tau
>>> x/y == print(x/y)
0.5
False
>>> x = 153
>>> y = 245
>>> print(x/y) == x/y
0.6244897959183674
False
>>> print(x+y) == x + y
398
False
>>> print(x*y) == x*y
37485
False
>>> s1 = 'Hello, '
>>> s2 = 'how are you?'
>>> print(s1 + s2) == s1 + s2
Hello, how are you?
False
>>> print(s1 + s2) is s1 + s2
Hello, how are you?
False
>>> type(print(s1 + s2))
Hello, how are you?
<class 'NoneType'>
>>> type(s1 + s2)
<class 'str'>
>>> type(print(y/x))
1.6013071895424837
<class 'NoneType'>
>>> type(x/y)
<class 'float'>

----------
assignee: terry.reedy
components: IDLE
messages: 339441
nosy: roccosan, terry.reedy
priority: normal
severity: normal
status: open
title: identity operator
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36524>
_______________________________________


More information about the New-bugs-announce mailing list