mirror of
https://github.com/satwikkansal/wtfpython
synced 2025-07-04 12:28:05 +02:00
example1.py
This commit is contained in:
parent
f8acf49d05
commit
8bb2aa296b
1 changed files with 14 additions and 0 deletions
14
example1.py
Normal file
14
example1.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
a=[11,22]
|
||||||
|
b=a
|
||||||
|
The ids of the two will be the same.
|
||||||
|
Now,
|
||||||
|
a[0]=1
|
||||||
|
The ids of the two will still be the same as both a and b are referring to the same location, changes made to a are made to b as well.
|
||||||
|
Hence,
|
||||||
|
a=[1,22]
|
||||||
|
b=[1,22]
|
||||||
|
|
||||||
|
Now if we do
|
||||||
|
import copy
|
||||||
|
c=copy.deepcopy(a)
|
||||||
|
id(a) will not be equal to id(c)
|
Loading…
Add table
Add a link
Reference in a new issue