8000 Section6 update · georgecms/complete-python-course@32028a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 32028a4

Browse files
committed
Section6 update
1 parent 6eba858 commit 32028a4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## IS
2+
- Return True if the operands have the same identity
3+
4+
Example:
5+
```
6+
users = ['James', 'Charlie', 'Ana']
7+
print(id(users)) # 2425142160952
8+
9+
users_copy = users
10+
print(id(users_copy)) # 2425142160952
11+
12+
print(users_copy is users) # True
13+
14+
users_copy = users[:]
15+
print(id(users_copy)) # 2425142558551
16+
17+
print(users_copy is users) # False
18+
```
19+
20+
## IS NOT
21+
- Returns True if the operands don't have the same identity
22+
23+
Example:
24+
```
25+
users = ['James', 'Charlie', 'Ana']
26+
print(id(users)) # 2425142160952
27+
28+
users_copy = users
29+
print(id(users_copy)) # 2425142160952
30+
31+
print(users_copy is users) # False
32+
33+
users_copy = users[:]
34+
print(id(users_copy)) # 2425142558551
35+
36+
print(users_copy is users) # True
37+
```

0 commit comments

Comments
 (0)
0