1
00:00:07,970 --> 00:00:13,170
When we have two variable names that point to the same value,

2
00:00:13,170 --> 00:00:15,225
things can start to get confusing.

3
00:00:15,225 --> 00:00:21,000
It's actually not too bad when we point to immutable objects.

4
00:00:21,000 --> 00:00:26,130
So for example, we have the variable a,

5
00:00:26,130 --> 00:00:37,215
pointing to banana and we've got b,

6
00:00:37,215 --> 00:00:40,770
also pointing to banana.

7
00:00:40,770 --> 00:00:44,515
Now, it turns out that with strings,

8
00:00:44,515 --> 00:00:48,425
the Python interpreter figures out that

9
00:00:48,425 --> 00:00:54,085
it's the same string banana and it makes a and b both point to it.

10
00:00:54,085 --> 00:00:57,485
So we have this operator is,

11
00:00:57,485 --> 00:01:03,065
which checks and tells us whether a and b are pointing to the same object,

12
00:01:03,065 --> 00:01:07,440
are they aliases for the same object?

13
00:01:09,500 --> 00:01:11,820
Here it says, "True",

14
00:01:11,820 --> 00:01:14,505
a and b are pointing to the same object.

15
00:01:14,505 --> 00:01:17,570
It's going to get a little more complicated for us when

16
00:01:17,570 --> 00:01:21,670
we start dealing with lists and other mutable objects.

17
00:01:21,670 --> 00:01:25,055
Here, we've got variables a and b,

18
00:01:25,055 --> 00:01:29,035
both pointing to lists that have equivalent values,

19
00:01:29,035 --> 00:01:33,355
but it turns out they aren't actually aliases for each other.

20
00:01:33,355 --> 00:01:35,740
Let's see this in codelens.

21
00:01:35,740 --> 00:01:46,260
So, the variable a, is bound to a list of three items 81, 82 and 83.

22
00:01:46,260 --> 00:01:48,150
Then we're going to assign b,

23
00:01:48,150 --> 00:01:50,444
to a list that's really equivalent,

24
00:01:50,444 --> 00:01:52,785
but it isn't the same list.

25
00:01:52,785 --> 00:01:56,380
So, we end up with two lists that each have the values 81,

26
00:01:56,380 --> 00:02:00,760
82 and 83, and then a is not an alias for b.

27
00:02:00,760 --> 00:02:03,240
So, when we print a as b,

28
00:02:03,240 --> 00:02:06,580
it tells us, "False".

29
00:02:13,100 --> 00:02:15,870
However, if we ask,

30
00:02:15,870 --> 00:02:18,945
"Does a equal equal b?",

31
00:02:18,945 --> 00:02:22,005
as we do on line six,

32
00:02:22,005 --> 00:02:25,110
it will tell us, "True".

33
00:02:27,800 --> 00:02:31,765
So, equal equal is an operator that checks whether

34
00:02:31,765 --> 00:02:37,515
two variables are bound to objects that are equivalent to each other.

35
00:02:37,515 --> 00:02:44,075
a is b checks whether a and b are aliases for exactly the same object.

36
00:02:44,075 --> 00:02:47,835
If we print the IDs of these two,

37
00:02:47,835 --> 00:02:51,250
we'll see that they are not the same.

38
00:02:56,990 --> 00:03:00,715
So, those are very long IDs.

39
00:03:00,715 --> 00:03:06,570
I just want to point out one other thing which is,

40
00:03:06,570 --> 00:03:13,870
that if we run this not in codelens but in the activecode window,

41
00:03:15,940 --> 00:03:23,600
we get the same answers false and true for whether a is b and whether a equal equals b,

42
00:03:23,600 --> 00:03:26,650
but the ID numbers are a little different.

43
00:03:26,650 --> 00:03:30,770
In codelens, the interpreter is running off on

44
00:03:30,770 --> 00:03:33,500
some remote computer and it's got

45
00:03:33,500 --> 00:03:36,895
a real Python interpreter where the ID numbers are really big.

46
00:03:36,895 --> 00:03:38,760
When we run it in codelens,

47
00:03:38,760 --> 00:03:40,705
it's doing something right in the browser,

48
00:03:40,705 --> 00:03:44,420
it's the only thing running and so it ends up with these small ID numbers.

49
00:03:44,420 --> 00:03:47,480
But the important thing to notice whether you run it in

50
00:03:47,480 --> 00:03:51,220
the activecode window or whether you run it in codelens,

51
00:03:51,220 --> 00:03:55,050
is that the two ID numbers are not the same.

52
00:03:55,050 --> 00:04:00,720
Three and four are different or these two ID numbers are different.