Dennie
asked on
rewrite function in python
def temp(self, check_node, node):
while getattr(node, 'parent_node', None):
node = node.parent_node
if check_node == node:
return True
--------
if self.temp(check_node,node):
do something
How can I rewrite def temp so I can directly use it in the if without having to create a seperate function?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't have an answer, but why do you want to get rid of the function?
It seems to make your code more readable.
At least if you gave the function a proper name like found_node_in_parents
It seems to make your code more readable.
At least if you gave the function a proper name like found_node_in_parents
Thanks for the grade & points.
Good luck & have a great day
Good luck & have a great day
Do you have an example initialized data structure?