passing self data into a recursive function

Posted by user272689 on Stack Overflow See other posts from Stack Overflow or by user272689
Published on 2010-03-14T18:42:57Z Indexed on 2010/03/14 18:45 UTC
Read the original article Hit count: 253

Filed under:
|
|

I'm trying to set a function to do something like this

   def __binaryTreeInsert(self, toInsert, currentNode=getRoot(), parentNode=None):

where current node starts as root, and then we change it to a different node in the method and recursivly call it again.

However, i cannot get the 'currentNode=getRoot()' to work. If i try calling the funcion getRoot() (as above) it says im not giving it all the required variables, but if i try to call self.getRoot() it complains that self is an undefined variable. Is there a way i can do this without having to specify the root while calling this method?

© Stack Overflow or respective owner

Related posts about python

Related posts about self