# Learn Special Methods by Building a Vector Space - Step 30

### Tell us what’s happening:

I do not understand the test. This is up to the level I understood.

``````
class R2Vector:
def __init__(self, *, x, y):
self.x = x
self.y = y

def norm(self):
return sum(val**2 for val in vars(self).values())**0.5

def __str__(self):
return str(tuple(getattr(self, i) for i in vars(self)))

# User Editable Region

def __repr__(self):
arg_list = [f'{key}={val}' for key, val in vars(self).items()]
args = ', '.join(arg_list)
return f'{__class__.__name__} {args}'

# User Editable Region

class R3Vector(R2Vector):
def __init__(self, *, x, y, z):
super().__init__(x=x, y=y)
self.z = z

v1 = R2Vector(x=2, y=3)
v2 = R3Vector(x=2, y=2, z=3)
print(f'v1 = {v1}')
print(f'v2 = {v2}')
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36`

### Challenge Information:

Learn Special Methods by Building a Vector Space - Step 30

This alone would raise an error. You need to reference the object of which you want to get the name. How do you reference the current instance in Python?

Then, think that the string used to instantiate the object should have this structure:
`ClassName(arg1, arg2, ..., argN)`

Once you add the reference to the current instance so that you are able to get the class name, you’d still have this instead:
`ClassName arg1, arg2, ..., argN`

By referencing the object that will be `self.__class__.__name__()`. If the parenthesis will there when I passed in the `args` argument it did not work. If the parenthesis will not be there then where do I pass the `args` argument?

You are writing a string, you are allowed to write things outside the replacement fields (`{}`).

If I write the `args` variable out the replacement field then it is now an ordinary string which means the `args` variable was not used. Without it the test is still not working

I’m saying you should write parentheses outside the replacement fields.

Aha!!! Thanks, it worked. Why does this `f'{self.__class__.__name__}({args})'` works and this `f'{self.__class__.__name__(args)}'` don’t?

1 Like

It doesn’t work because `self.__class__.__name__` returns a string and so it’s not callable. If you append a pair of parentheses to it, it would raise an error when evaluated.

1 Like

Thanks. I will try to rap my head around it.

1 Like

Thanks for this conversation which has also helped me!

1 Like