Skip to content

s/isinstance/type/ #62

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

Merged
merged 1 commit into from
Nov 6, 2018
Merged

s/isinstance/type/ #62

merged 1 commit into from
Nov 6, 2018

Conversation

kzidane
Copy link
Member

@kzidane kzidane commented Nov 6, 2018

No description provided.

@kzidane kzidane requested a review from dmalan November 6, 2018 14:57
dmalan
dmalan previously approved these changes Nov 6, 2018
Copy link
Member

@dmalan dmalan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Is == definitely best as opposed to is (not isinstance)?

@kzidane
Copy link
Member Author

kzidane commented Nov 6, 2018

@dmalan I think they're practically the same in this case. Changed to is for readability.

@dmalan
Copy link
Member

dmalan commented Nov 6, 2018

Does practically mean there's some difference though?

@kzidane
Copy link
Member Author

kzidane commented Nov 6, 2018

Well, yes. == checks if two values are the same while is checks if two instances are the same. If two values are equal, that doesn't necessarily mean that they're the same instance.

>>> ls = [1, 2, 3]
>>> lss = [1, 2, 3]
>>> ls == lss
True
>>> ls is lss
False

@dmalan
Copy link
Member

dmalan commented Nov 6, 2018

Right, but what does "practically the same in this case" mean? :)

@kzidane
Copy link
Member Author

kzidane commented Nov 6, 2018

Because the class instances we're comparing are singleton so using either (is or ==) doesn't matter (they should evaluate to the same value).

>>> (type(42) == int) == (type(42) is int)
True

@kzidane kzidane merged commit 4cfc648 into develop Nov 6, 2018
@kzidane kzidane deleted the type branch November 6, 2018 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants