Type() not detecting my class (Tree) in Python 3 -
came across cannot understand properly. please have @ piece of code below. part of program converting binary tree list , record file. problem have fails detect tree object , skips else: part of if statement. put print type(t) in loop before going if statement check if tree object end shows:
<class '__main__.tree'>
but python still skips if clause (i tried type(t) tree , type(t) == tree, same result). there must not understand if can see please let me know.
variables @ first step after program skips damn if clause , goes else no reason can grasp :) :
copy = {list} <class 'list'>: [<__main__.tree object @ 0x0000001eaae549b0>] t = {tree} can bark cargo = {str} 'can bark' while len(bot_level) > 0: copy = bot_level[:] t in copy: print(type(t)) if isinstance(t, tree): cargo_list.append(t.cargo) bot_level.append(t.left) bot_level.append(t.right) del bot_level[0] else: cargo_list.append(none) del bot_level[0]
Comments
Post a Comment