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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:04:27+00:00 2026-05-23T14:04:27+00:00

I have a function: def greeter(name, greeting, punc): print greeting+’, ‘+name+punc I have a

  • 0

I have a function:

def greeter(name, greeting, punc):
    print greeting+', '+name+punc

I have a dictionary with parameters:

params={'name':'Mark','greeting':'How are you','punc':'?'}

When I call the function as greeter(**params), I get the expected output How are you, Mark?. But When I call like this greeter(*params), I get the output name, puncgreeting. Looks like a list of keys from params has been passed to greeter. What is actually happening here?

Just curious.

  • 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-23T14:04:28+00:00Added an answer on May 23, 2026 at 2:04 pm

    Looks like a list of keys from params has been passed to greeter. What is actually happening here?

    That is indeed what is happening, more or less.

    *x expects x to be an iterable, and iterates over it, interpreting the results as arguments one by one. Iterating over a dict, by default, iterates over its keys. (You could get name/value pairs instead, for example, with greeter(*(params.items())), but the dict would still be unsorted so order of iteration would be unreliable.)

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

Sidebar

Related Questions

Let's say I have this function: def print_a_line(line_count, f): print line_count, f.readline() I call
I have a function that accepts wildcard keyword parameters: def func(**kargs): doA doB How
i have a function : def tong_thoigian (self,cr,uid,ids,context={}): obj=self.browse(cr,uid,ids,context=context)[0] cr.execute('''select name,giolam from x_giolam where
I am writing a script and in my script I have this function: def
In python I have the following function: def is_a_nice_element(element, parameter): #do something return True
I have a function that presents the user a combo-box. def select_interface(interfaces) list_box :items
I have a function which returns 3 numbers, e.g.: def numbers(): return 1,2,3 usually
I have a decorated function (simplified version): class Memoize: def __init__(self, function): self.function =
Say I have a Python function that returns multiple values in a tuple: def
I have the following function: >>> def rule(x): ... rule = bin(x)[2:].zfill(8) ... rule

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.