You want to use None
to imply that there is no valid object. You want to use []
to imply an object that is of type list and has no elements.
[None]
is a list with one element which is None
>>>c= [] # This is a new list object
>>>d= [] # This is another new list object
In Python , x is y
is used to check whether x
and y
are the same objects.
Here, c
and d
point to different list objects.
so,
>>>print c is d
False
is expected.
On the other hand,
>>>c= [] # This is a new list object
>>>d = c # This is the same object as c
>>>print c is d
True
Here, a and b are primitives, not objects
>>>a= 1
>>>b=1
So, this is expected:
print a is b
True