Skip to content

Commit e46f601

Browse files
committed
Use isinstance, not type.
1 parent d07fa54 commit e46f601

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

python-tips.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Python Tips
22

3+
## Use isinstance(), not type()
4+
type() only tells you the name of the class lowest in the hierarchy.
5+
isinstance() tells you whether the object inherits from the given class, so
6+
it works for child classes.
7+
38
## List, set, and dictionary comprehensions
49
```python
510
my_list = []

0 commit comments

Comments
 (0)