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
You can use keyword arguments:
By the way, it’s looking like you’re reimplementing complex numbers. Those are already built in to Python, try
complex(3,4)or3+4j.