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 8221847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:04:36+00:00 2026-06-07T14:04:36+00:00

So I have a function defined as such: def getDistnace(self, strings, parentD, nodeName, nodeDistance):

  • 0

So I have a function defined as such:

def getDistnace(self, strings, parentD, nodeName, nodeDistance):

And I am calling it with:

Node.getDistnace(newNode, strings, parentD, nodeName=None, nodeDistance=None)

and

Node.getDistnace(node, strings=None, parentD=None, nodeName, nodeDistance)

Which are both from 2 other different functions. But my problem is that I get an error stating there is a non-keyword arg after keyword arg.

Is there any way around this error? The first Node.getDistnace adds strings and parentD to getDistance, and the second Node.getDistnace adds nodeName and nodeDistance to the function.

  • 1 1 Answer
  • 0 Views
  • 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-06-07T14:04:38+00:00Added an answer on June 7, 2026 at 2:04 pm

    All your arguments are positional, you don’t need to use keywords at all:

    Node.getDistnace(newNode, strings, parentD, None, None)
    
    Node.getDistnace(node, None, None, nodeName, nodeDistance)
    

    I think you are confusing local variables (what you pass into the function) and the argument names of the function. They happen to match in your code, but there is no requirement that they do match.

    The following code would have the same effect as your first example:

    arg1, arg2, arg3 = newNode, strings, parentD
    Node.getDistnace(arg1, arg2, arg3, None, None)
    

    If you do want to use keyword arguments, that’s fine, but they cannot be followed by positional arguments. You can then alter the ordering and python will still match them up:

    Node.getDistnace(node, nodeDistance=nodeDistance, strings=None, parentD=None, nodeName=nodeName)
    

    Here I moved nodeDistance to the front of the keyword arguments, but Python will still match it to the last argument of the getDistnace method.

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

Sidebar

Related Questions

I have some nice dialogues defined as such in jQuery: <script type=text/javascript> $(document).ready(function() {
I have Javascript function defined in the main index.html file. One part of this
I have a function defined like this: public static void ShowAbout(Point location, bool stripSystemAssemblies
i have a function defined as follows: void AddHeadCode(std::ofstream &ostream, size_t length){ ostream.write((char*)length, sizeof(length));
I have a function defined inside the script tags of head.(in a JSP) I
Suppose I have a function defined like this: class Foo() { public: void bar(MyClass*
MyActivity implements a CustomListener defined in MyClass.java. I have a function defined in MyClass
In an ASP.MVC application, I have a function defined in my _ViewStart.cshtml like this:
It's a very simple program. I have a function defined on the top and
I have template function compare defined as below. #include<iostream> using namespace std; template<typename T>

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.