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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:12:59+00:00 2026-05-31T10:12:59+00:00

i need to pass a parameter list stored in a dictionary to a function

  • 0

i need to pass a parameter list stored in a dictionary to a function
implemented by an ironPython class.

I have prepared the minimum example that reproduces the error:

        // C# Side
        var runtime = Python.CreateRuntime();
        dynamic test = runtime.UseFile("test.py");

        // Here the parameters dictionary is instantiated and filled
        var parametersDictionary = new Dictionary<string, int>();
        parametersDictionary.Add("first", 1);

        // The Python 'x' instance is called passing parameter dictionary
        var result = test.x.ReturnFirstParameter(parametersDictionary);

Now the Python code:

# Python side

# Class 'Expression' definition
class Expression(object):
    def ReturnFirstParameter(self, **parameters):
        return parameters['first']

# Class 'Expression' instantiation
x = Expression()

When i run the program, i get the following exception:

ReturnFirstParameter() takes exactly 1 argument (2 given)

The first parameter is ‘self’, but it seems like ignoring it receives
2 parameters, ‘self’ and the dictionary.

I have tried changing the dictionary for other parameters and it works well. The problem
only arises when you receive a ** parameter.

I deeply appreciate your help!

Esteban.

  • 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-05-31T10:13:00+00:00Added an answer on May 31, 2026 at 10:13 am

    It should work to simply remove the ** from in front of parameters in the Python code:

    class Expression(object):
        def ReturnFirstParameter(self, parameters):
            return parameters['first']
    

    ** should be used when you are passing in named parameters to a function, and your C# code will be passing a dictionary.

    Your C# code would call the function like this:

    x.ReturnFirstParameter({'first': 1})
    

    For it to work with **parameters the call would need to be

    x.ReturnFirstParameter(first=1)
    

    There may be a way to do this with ironpython but I’m not sure how.

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

Sidebar

Related Questions

I have list of files stored inside arraylist that I need to download in
This question is regarding getopt function in php. I need to pass two parameter
I have a rather silly question, I need to pass a parameter from one
I have a function with many input parameters, and I need a function that
I need to pass a list of key values to a stored procedure in
Hi What paratemeter I need to pass to this function. It is taking 00c0c0c0
How would I pass a list of values into a function, where the values
I need to pass the lambda query as a parameter, the followings code is
I'm using SmartPart 1.3 to develop web-parts to SharePoint. I need pass parameter to
I need to pass to my subreport a list of integers which will be

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.