1

Why can't I compare a string with a string containing an operator?

My issue:

python
Python 3.7.2 (default, Jan 10 2019, 23:51:51)
[GCC 8.2.1 20181127] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> val = "<="
>>> val
'<='
>>> val is "<="
False
>>>

Edit #1: I just now realized == works, but why is this? Surely they should both return true?

Edit #2: I'm an idiot, thanks for the info!

martineau
  • 119,623
  • 25
  • 170
  • 301

0 Answers0