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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:21:14+00:00 2026-06-10T23:21:14+00:00

I am trying to make my code NOT to accept keyword arguments just like

  • 0

I am trying to make my code NOT to accept keyword arguments just like some bulitins also do not accept keyword arguments, but, I am unable to do so. Here, is my thinking according to my limited understanding:-

def somefunc(a,b):
    print a,b

somefunc(10,20)

Output:

10 20

Now, When I run the following (I know this is not expected to be keyword argument in the function definition, but, looking at the function call, it seems to be the same syntax as that of when calling a function which accepts keyword arguments):

somefunc(b=10,a=20)

Output:

20 10

I have 2 questions:-

  1. Looking at the function call somefunc(b=10,a=20) and not the function definition, this can seem to be either of a call to a function which accepts just normal arguments or a function which accepts keyword arguments. How does the interpreter differentiate between the two?
  2. Is it possible to convert any of our function in a form so that it does not accept keyword arguments just like many of the builtins do?

Why I want to do this at all?
I am just checking if I can do this, so that I do not miss anything in understanding python in depth. I do knot know whether python allows that or not.

  • 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-10T23:21:15+00:00Added an answer on June 10, 2026 at 11:21 pm

    ad 1) Correct names are verified automatically by Python if they are called like somefunct(name=value, ...). I don’t need to remember the exact standard order of parameters and to verify it too "neurotic" by looking into the documentation every month at every usage, if I remember a function with nice descriptive names of parameters. A call with named parameters can be easily verified by a test or by use. On the contrary, the correct order of used parameters can be verified only by reading the documentation. Calling by named parameters is preferred over a very long list of positional parameters. Therefore the reported behavior is well-founded. (Short single letter parameters "a, b" don’t help against mistakes of course.)

    ad 2) Positional-only parameters defined in Python code are possible in Python 3.8 and newer by a new function parameter syntax / to indicate that some function parameters must be specified positional and cannot be used as keyword arguments.

    def somefunc(a, b, /):
        print(a, b)
    

    Originally it was possible only in C. Some well known builtin fast functions written in C with small fixed number of required parameters typically do not support calling with named parameters. (e.g. hasattr)

    This is because they use only a fast simple header ...(... PyObject *args) and therefore all named parameters are rejected automatically. (Python can never introspect into names of arguments in C source. 🙂

    Many other C functions have a header ...(... PyObject *args, PyObject *kwds) and they support exact list of names explicit by implementing much more complicated validation PyArg_ParseTupleAndKeywords. These names must be written to docs strings manually.


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

Sidebar

Related Questions

I am working with someone else's code and trying to make some modifications. So
I'm trying to make a code that will show two different images depending on
I'm trying to make this code generic: public final Object unwrap(Class arg0) { throw
I am trying to make my code more clear using the include function of
2 short questions based on trying to make my code more efficient (I think
im totally new when it comes to trying to make HTML code. I was
I'm trying to make a genric code to serialize and deserialize any object that
I am trying to make a frame from code so that I can apply
I'm trying to make a part of my code more fluent. I have a
I'm trying to make a time with Time.local which in my code is dynamic.

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.