if statement - Python what does if 'self.root' do? -
for example:
def __init__(self): self._root = none def get(self, key): if self._root: return self._root.get(key).value raise keyerror
what if self._root:
return? self._root
not boolean.
well there many ways @ it. straight forward way check happen simple, check flow simple "if" statement.
>>> if none: ... print("true") ... else: ... print("false") ... false
now, more indicative, can check non "none" value , see happens.
>>> = "asf" >>> if a: ... print("true") ... else: ... print("false") ... true >>> = none >>> if a: ... print("true") ... else: ... print("false") ... false
so if statement got there checks if self._root none or not, , calls method of if it's not none.
Comments
Post a Comment