In python 2 only (not python 3):
assert not isinstance(lst, basestring)
Is actually what you want, otherwise you’ll miss out on a lot of things which act like lists, but aren’t subclasses of list
or tuple
.
More Related Contents:
- List vs tuple, when to use each? [duplicate]
- Check if all elements of a list are of the same type
- convert string to list [duplicate]
- Unable to use convert strings into integers for a for loop
- List of lists changes reflected across sublists unexpectedly
- Strange result when removing item from a list while iterating over it
- How to merge lists into a list of tuples?
- Pythonic way to print list items
- Pythonic way to check if a list is sorted or not
- Detecting consecutive integers in a list [duplicate]
- List comprehension vs. lambda + filter
- Non-alphanumeric list order from os.listdir()
- Python – use list as function parameters
- How to extract parameters from a list and pass them to a function call [duplicate]
- Sum of list of lists; returns sum list
- List of tuples to dictionary [duplicate]
- case-insensitive list sorting, without lowercasing the result?
- str.startswith with a list of strings to test for
- Python Array Slice With Comma?
- How to split strings inside a list by whitespace characters
- Complexity of list.index(x) in Python
- How to transform string of space-separated key,value pairs of unique words into a dict
- Python range() and zip() object type
- Python: find closest string (from a list) to another string
- How to override the slice functionality of list in its derived class
- How do I merge multiple lists into one list? [duplicate]
- Python: filtering lists by indices
- What are dict_keys, dict_items and dict_values?
- How do I send list of dictionary as Body parameter together with Files in FastAPI?
- deque.popleft() and list.pop(0). Is there performance difference?