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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:34:05+00:00 2026-06-01T13:34:05+00:00

I made a class which looks something like. class NewInt: def __init__(self, x,y): self.holders

  • 0

I made a class which looks something like.

class NewInt:
  def __init__(self, x,y):
    self.holders = {"x":x,"y":y}

Now, I have a number say a dictionary. So everything is exactly same

except its not NewInt but a dict.Somethng like

 A  {"x": 3,"y":4}

So it is exactly of type NewInt except its a dictionary.

Is there a way i can do something like

this_int = NewInt(A)

I forgot but there was a special name to such constructor where assignment is done ??
Thanks

  • 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-01T13:34:06+00:00Added an answer on June 1, 2026 at 1:34 pm

    You can use keyword arguments:

    A = {"x": 3,"y":4}
    this_int = NewInt(**A)
    

    By the way, it’s looking like you’re reimplementing complex numbers. Those are already built in to Python, try complex(3,4) or 3+4j.

    • 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 objects which look very roughly like this: class object {
I have made an class which conforms to the NSCoding protocol and does all
How can I unit test my NSURLConnection delegate? I made a ConnectionDelegate class which
I've got a class (which extends MovieClip) that loads in an external SWF (made
I've made an custom UILabel class in which i draw a red line at
I have a class2 which is involved by class1 when clicks are made. I
I am learning C++ and I have a question. I made a class in
my friend has made a really helpful class library which I use all the
I have a stateless, abstract base class from which various concrete classes inherit. Some
I must have done something very stupid which has caused the following situation. Basically

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.