2016: IS_vs_==.py
File IS_vs_==.py, 513 bytes (added by , 9 years ago) |
---|
Line | |
---|---|
1 | # "is" bo vrnil "True" v primeru, ko bosta obe spremenljivki kazali na isti objekt v spominu (RAM-u), torej bo slo za |
2 | # isto lokacijo. |
3 | # "==" pa govori le o enakosti vrednosti obeh objektov |
4 | a = 10 |
5 | b = float(a) |
6 | print("With 'a is b' we get -> ", a is b) |
7 | print("With 'a == b' we get -> ", a == b) |
8 | |
9 | c = [1, 2, 3] |
10 | d = c |
11 | print("With 'c is d' we get -> ", c is d) |
12 | print("With 'c == d' we get -> ", c == d) |
13 | |
14 | e = c[:] |
15 | print("With 'e is c' we get -> ", e is c) |
16 | print("With 'e == c' we get -> ", e == c) |