Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When judge the iterable got NameError: name 'Iterable' is not defined

Tags:

python

I follow the tutorial:

enter image description here

In my PyCharm I follow the tutorial:

enter image description here

I get the error:

Traceback (most recent call last): File "/Users/adob/TestPython/test02/passwd.py", line 19, in bool = isinstance({}, Iterable) NameError: name 'Iterable' is not defined

like image 779
user7693832 Avatar asked Oct 26 '25 16:10

user7693832


2 Answers

from collections import Iterable

bool = isinstance({},Iterable)
print(bool)

Output

True

like image 122
Hariom Singh Avatar answered Oct 28 '25 05:10

Hariom Singh


The Iterable is in the collections module, you should import it.

from collections import Iterable
like image 22
aircraft Avatar answered Oct 28 '25 05:10

aircraft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!