Skip to content

Conversation

@NickSto
Copy link
Contributor

@NickSto NickSto commented Dec 28, 2019

The existing example doesn't actually function as intended, and it doesn't really demonstrate the idea very well.

The reason stated for using isinstance() instead of comparing type()s is that isinstance() handles inheritance. So I'm not sure why the second example uses two unrelated classes Rectangle and Circle. The obvious choice is to use Rectangle and Square, as in this fix.

And I'm not sure what the idea was with the third example, either. The Rectangle object is not a ListType, and I'm not sure why one would think it is. So I changed it to be a repeat of the worst practice example, except using the best practice to compare.

@adewes adewes merged commit 0d6b417 into quantifiedcode:master Feb 28, 2020
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.

2 participants