Different behavior in python script and python idle?
问题 In the python idle: >>> a=1.1 >>> b=1.1 >>> a is b False But when I put the code in a script and run it, I will get a different result: $cat t.py a=1.1 b=1.1 print a is b $python t.py True Why did this happen? I know that is compares the id of two objects, so why the ids of two objects are same/unique in python script/idle? I also found that, if I use a small int, for example 1 , instead of 1.1 , the result will be the same in both the python script and python idle. Why did small int and