Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 675783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:51:22+00:00 2026-05-14T00:51:22+00:00

I’m trying to set a function to do something like this def __binaryTreeInsert(self, toInsert,

  • 0

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?

EDIT: The base case of this method is already

if currentNode == None:

so using that to set the root wouldn’t work

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:51:23+00:00Added an answer on May 14, 2026 at 12:51 am

    While arg=None is the idiomatic Python sentinel value for an non-supplied argument, it doesn’t have to be None. In Lua, for instance, the idiomatic non-supplied argument is an empty table. We can actually apply that to this case:

    class Foo:
        sentinel = {}
        def bar(self, arg=sentinel):
            if arg is self.sentinel:
                print "You didn't supply an argument!"
            else:
                print "The argument was", arg
    
    f = Foo()
    f.bar(123)
    f.bar()
    f.bar(None)
    f.bar({})
    

    Output:

    The argument was 123
    You didn't supply an argument!
    The argument was None
    The argument was {}
    

    This works for any case except explicitly passing Foo.sentinel, because Foo.sentinel is guaranteed to have a unique address — meaning, x is Foo.sentinel is only true when x is Foo.sentinel 🙂 Thus, due to the closure we’ve created around Foo.sentinel, there is only one object that can create an ambiguous situation, and it will never be used by accident.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 381k
  • Answers 381k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm assuming that (a,b,c) is unique. One way to do… May 14, 2026 at 10:03 pm
  • Editorial Team
    Editorial Team added an answer you need to put def action_name output = `/path/to/your/shell/script` end… May 14, 2026 at 10:03 pm
  • Editorial Team
    Editorial Team added an answer Seems like a very reasonable approach. Personally I'd go with… May 14, 2026 at 10:03 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.