[Flask] Shouldn't is and == operator work same way while doing string comparisons?
Tim Johnson
tim at akwebsoft.com
Sun May 5 20:54:50 EDT 2019
* Gergely Polonkai <gergely at polonkai.eu> [190503 21:20]:
> …in fact, i can easily give OP a counterexample with strings:
>
> >>> a = 'hello' + ' world'
> >>> b = 'hello world'
> >>> a
> 'hello world'
> >>> b
> 'hello world'
> >>> a == b
> True
> >>> a is b
> False
>
>
>
> Gergely Polonkai
> [image: https://]about.me/gergely.polonkai
> <https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
Another way of looking at what Gergely puts it is that variables a
and b may contain equal contents but they have different addresses
in memory.
They are in fact NOT the same object
--
Tim Johnson
http://www.tj49.com
More information about the Flask
mailing list