vino19 wrote: > Hello, I'm a newbie. > What's the defference between > >>>>a=-6; b=-6; a is b >>>>True > > and > >>>>a=-6 >>>>b=-6 >>>>a is b >>>>False > > ?
When you write it as a single line the assignments to a and b are part of the same compilation process, and as an optimization CPython's bytecode compiler looks for identical (integer, float, string) constants and uses the same object to represent them. To show that it's really the compilation not the number of lines: >>> exec """a = -6 ... b = -6 ... """ >>> a is b True -- http://mail.python.org/mailman/listinfo/python-list