satwikkansal/wtfpython

It seems like one sample in "Section: Strain your brain! --> Strings can be tricky sometimes *" has been not suitable for Python 3.7.1?

RocShi opened this issue · 5 comments

Hello, thanks for your great effort in wtfpython. In practice, the result of last sample of 2nd code segment in Strings can be tricky sometimes * is different with that of mine. In wtfpython, it's like:

>>> a, b = "wtf!", "wtf!"
>>> a is b
True

But in my development environment, it's like:

$ python3
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a, b = "wtf!", "wtf!"
>>> a is b
False

My development environment is as follows.

  • windows 10 Enterprise (64-bit) based on x64 processor

  • Python 3.7.1 (64-bit)

So, is the sample mentioned above not suitable for Python 3.7.1?

It seems new in Python3.7
I ran these on 3.7.0 and 3.6.6 and got different results.

>>> # 3.7
>>> a, b = "wtf!", "wtf!"
>>> a is b
False
>>> a, b = "wtf", "wtf"
>>> a is b  # Still works
True
>>> # 3.6
>>> a, b = "wtf!", "wtf!"  # or a, b = "wtf", "wtf"
>>> a is b
True

I don't know why there's a change, but there's a problem, for sure :)

Edit : From what I understand, it might be due to one of these two PEPs : 538 & 540

@Ricocotam I have read PEP 538 and PEP 540, maybe you are right.

I don't know how it would affect this, but it's the only thing I can see from Python 3.7 change logs that could modify the behavior

Hey @RocShi thanks for highlighting this. I'm digging in deeper to find out what exactly caused this behavior change, and will update the example in the next release :)

This is similar to issue encountered in "is is not what it is" example. So closing this in favor of #100 , let's continue the discussion there :)