Hi Python Friends, I came across an example which is as below,
>>> var = [1, 12, 123, 1234] >>> var [1, 12, 123, 1234] >>> var[:0] [] >>> var[:0] = var >>> var [1, 12, 123, 1234, 1, 12, 123, 1234] >>> Here in var[:0] = var we are assigning an entire list to the beginning of itself. So shouldn't it be something like, [[1, 12, 123, 1234], 1, 12, 123, 1234] It happens when we do the below, >>> var = [1, 12, 123, 1234] >>> var[0] = var >>> var [[...], 12, 123, 1234] >>> Literally var[0] = var and var[:0] = var almost meens the same. But why is the difference in output? Can anyone explain what happens when slicing assignment and direct assignment. Regards, Krishnan
-- http://mail.python.org/mailman/listinfo/python-list