Does this:
if key == \"name\" and item:
mean the same as this:
if key == \"name\" and if key == \"item\":
If you look at the code for example 5.14:
def __setitem__(self, key, item):
if key == "name" and item:
self.__parse(item)
FileInfo.__setitem__(self, key, item)
item
is a variable, similar to how key is.
It can be used in the if
statement if it evaluates into either true
or false
.
eg.
happy = True
name = "Peter"
if name == "Peter" and happy:
print name + " is happy!"