简体   繁体   中英

How can I use isinstance() here instead of comparing types?

I`m trying to compare these two variables and pylint gives me an error.

I have no ideea how to do it without comparing types.

for key in first_dict.keys():
    if type(first_dict[key]) != type(second_dict[key]):
        new_dict[key] = (first_dict[key], second_dict[key])

The error looks like this:

C: 13,11 Using type()instead of isinstance() for a typecheck. (unidiomatic-typecheck)
if not isinstance(first_dict[key], type(second_dict[key]))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM