Reference
ast
nomail at invalid.com
Mon Mar 3 04:42:30 EST 2014
More information about the Python-list mailing list
Mon Mar 3 04:42:30 EST 2014
- Previous message (by thread): Origin of 'self'
- Next message (by thread): Object identity (was: Reference)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
hello Consider following code: >>> A=7 >>> B=7 >>> A is B True I understand that there is a single object 7 somewhere in memory and both variables A and B point toward this object 7 now do the same with a list: >>> l1 = [1, 2] >>> l2 = [1, 2] >>> l1 is l2 False It seems this time that there are 2 distincts objects [1, 2] in memory. l1 points toward the first one and l2 points toward the second one. if I change one, the second remains unchanged >>> l1.append(3) >>> l1 [1, 2, 3] >>> l2 [1, 2] I dont really understand why the behavior is different. Both integer 7 and list [1, 2] are objects. Why is it different ? thanks
- Previous message (by thread): Origin of 'self'
- Next message (by thread): Object identity (was: Reference)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list