python - Different ways of deleting lists -
i want understand why: a = [] ; del a ; and del a[:] ; behave differently. i ran test each illustrate differences witnessed: >>> # test 1: reset = [] ... >>> = [1,2,3] >>> b = >>> = [] >>> [] >>> b [1, 2, 3] >>> >>> # test 2: reset del ... >>> = [1,2,3] >>> b = >>> del >>> traceback (most recent call last): file "<stdin>", line 1, in <module> nameerror: name 'a' not defined >>> b [1, 2, 3] >>> >>> # test 3: reset del a[:] ... >>> = [1,2,3] >>> b = >>> del a[:] >>> [] >>> b [] i did find different ways of clearing lists , didn't find explanation differences in behaviour. can clarify this? test 1 >>> = [1,2,3] # set point list [1, 2, 3] >>> b = # set b pointing @ >>> = [] # set point empty list # step 1: --> [1