Is Keyword In Python
When I read 'Learning Python', I'm confused about using the is operator. The book tries to explain it as a test for the same memory address (A is B, if True, means A and B are in t
Solution 1:
This is an implementation detail of CPython (the standard Python interpreter), which will reuse the same data in memory for some immutable types such as strings and integers. You can't rely on such behavior, therefore you should always use ==
to compare such types.
For a more in-depth answer, see https://stackoverflow.com/a/15541556/1544347
Post a Comment for "Is Keyword In Python"