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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:17:14+00:00 2026-06-02T23:17:14+00:00

I am creating a module in python that can take multiple arguments. What would

  • 0

I am creating a module in python that can take multiple arguments. What would be the best way to pass the arguments to the definition of a method?

def abc(arg):
    ...

abc({"host" : "10.1.0.100", "protocol" : "http"})
def abc(host, protocol):
    ...

abc("10.1.0.100", "http")
def abc(**kwargs):
    ...

abc(host = "10.1.0.100", protocol = "http")

Or something else?

Edit

I will actually have those arguments (username, password, protocol, host, password2) where none of them are required.

  • 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-02T23:17:15+00:00Added an answer on June 2, 2026 at 11:17 pm
    def abc(host, protocol):
        ...
    
    abc("10.1.0.100", "http")
    abc(host="10.1.0.100", protocol="http")
    

    If you call it using positional args or keyword args depends on the number of arguments and if you skip any. For your example I don’t see much use in calling the function with keyword args.


    Now some reasons why the other solutions are bad:

    abc({"host" : "10.1.0.100", "protocol" : "http"})
    

    This is a workaround for keyword arguments commonly used in languages which lack real keyword args (usually JavaScript). In those languages it is nice, but in Python it is just wrong since you gain absolutely nothing from it. If you ever want to call the functions with args from a dict, you can always do abc(**{...}) anyway.

    def abc(**kwargs):
    

    People expect the function to accept lots of – maybe even arbitrary – arguments. Besides that, they don’t see what arguments are possible/required and you’d have to write code to require certain arguments on your own.

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

Sidebar

Related Questions

When creating a class in Python, I can simply make a def __len__(self): method
I am creating a python module that is implemented in C++. I am using
I'm creating a Python module. My question is how can I organize the distribution
Im creating a ServiceMix module that consists of a Camel route. In my beans.xml,
I'm creating an admin module for my client that gives them access to some
I'm creating a DotNetNuke module that needs to read entries from a SQL Server
In Magento I'm creating a custom module and would love to be able to
Is there any module for creating Excel charts with embedded charts in Python? The
I'm creating a basic database utility class in Python. I'm refactoring an old module
I'm creating additional module to already multi-module maven project. And for this one I

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.