First, the second factor of isinstance() can be tuple-type
assert isinstance(lst, list) or isinstance(lst, tuple)
can be reduced to assert is instance(lst, (list, tuple))
.
And when you use the ASSERT, I think
assert not isinstance(lst, basestring)
I think it's a better way to use it
(Please change to string
since Python 3 cannot use basestring
)
If you write it like the way you asked,
Although it is not subclass
in list
/tuple
, assertionError
occurs in other types that behave like list
/tuple
.
© 2024 OneMinuteCode. All rights reserved.