TypeError: doInOrden() missing 2 required positional arguments: 'probe' and 'visit'

For me not much experience just run some code have face the error required two positional arguments probe and visit please help me

   def viewIndex(self):
        '' 'Show words alphabetically with their occurrences' ''
        print(u"\n The alphabetical organization of the words in the tree is as follows:")
        self.probe = None
        self.visit = None
        self.getBTree().doInOrden()

Traceback (most recent call last):
  File "D:/btree-word-finder-master/btree-word-finder-master/Code_and_texts/BTreeWordFinder.py", line 102, in <module>
    BTreeWordFinder.main()
  File "D:/btree-word-finder-master/btree-word-finder-master/Code_and_texts/BTreeWordFinder.py", line 97, in main
    b.viewIndex()
  File "D:/btree-word-finder-master/btree-word-finder-master/Code_and_texts/BTreeWordFinder.py", line 49, in viewIndex
    self.getBTree().doInOrden()
TypeError: doInOrden() missing 2 required positional arguments: 'probe' and 'visit'

Welcome to the Anvil Community Forum!

This is not an Anvil-specific problem, just an ordinary Python one. Actually, this can happen in any programming language that lets you call functions, passing parameters explicitly (i.e., between parentheses after the function name).

So the member function doInOrden expects two parameters to be passed at the point of call. But look at the call:

There are zero parameters being passed to doInOrden.

Based on your code, it looks like you expect doInOrden to automatically find its parameters, by name, in viewIndex’s self object. By default, functions don’t work that way: they only receive the parameters you explicitly give them, between the parentheses, after the function’s name.

In this case, I think what you’re trying to do would be written

self.getBTree().doInOrden(None, None)

or, if self really needs to remember probe and visit,

self.getBTree().doInOrden(self.probe, self.visit)
2 Likes

Thanks a lot get the points