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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:02:45+00:00 2026-05-30T15:02:45+00:00

I looked into the example here C-like structures in Python But The example is

  • 0

I looked into the example here C-like structures in Python

But The example is of “bunch” but anyways the code is here

class Bunch:
def __init__(self,  **kwds):
    self.__dict__.update(kwds)

BUt I am using it like this

p = Bunch(x,y)

BUt I am getting a type error

TypeError: __init__() takes exactly 1 argument (3 given)

What am I doing wrong??

  • 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-30T15:02:47+00:00Added an answer on May 30, 2026 at 3:02 pm

    You have to pass keyword arguments. Otherwise it doesn’t know the names you want to give to the attributes x and y.

    Try

    p = Bunch(x=x, y=y)
    

    To amplify on this, when you see **argname in the arguments to a function or method, it has a very specific meaning. It means take all keyword arguments passed to the function that aren’t already named and combine them together into a dict called argname. See below for an example.

    >>> class Bunch(object):
    ...     def __init__(self, **kwargs):
    ...         self.__dict__.update(kwargs)
    ...         print kwargs
    ... 
    >>> x, y = 5, 6
    >>> p = Bunch(x=x, y=y)
    {'y': 6, 'x': 5}
    >>> p.x
    5
    >>> p.y
    6
    

    If you try to pass non-keyword args to a function that only accepts **kwargs, you’ll get an error.

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

Sidebar

Related Questions

I've looked into the API Demos and they have an example of the gallery
I haven't really looked into the new .NET stuff since 2.0, but I'm wondering
I've looked into the DesignOnly attribute, but that doesn't seem to accomplish what I
I've looked into some questions here where the best programming books are listed and
I would like to catch and log MySQL warnings in Python. For example, MySQL
I've looked into SQL 2008's built-in Full-Text search, and also Lucene.NET.. but I don't
Ok, I ran into this tree question which LOOKED simple, but started driving me
I recently looked into Prism (aka the Composite Application Library for WPF) and really
Is there anyone who has used or looked into using Jitterbit as well as
What is a good way to edit a Web.config file programmatically? I looked into

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.