Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__neg__: Should use class(self)(...) instead of Vector(...) #1

Open
Grazfather opened this issue Jan 31, 2017 · 0 comments
Open

__neg__: Should use class(self)(...) instead of Vector(...) #1

Grazfather opened this issue Jan 31, 2017 · 0 comments

Comments

@Grazfather
Copy link

@Grazfather Grazfather commented Jan 31, 2017

In your solution to vector you use Vector:

    def __neg__(self):
        return Vector(-x for x in self)

You also hardcode Vector in __add__.

Above it, though, in __getitem__ you get the class by using class(self). This seems inconsistent, and probably incorrect. If you were to subclass Vector, for instance, it would break when negating an instance of the subclass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.