QuestionQ18

VerifiedPython/PyEZ

You are troubleshooting a Python script and want to determine which kind of data structure a certain object is.

Which built-in function would you use to accomplish this task?

Explanation

The type() built-in function returns the class or data type of an object, making it the appropriate tool for identifying whether an object is, for example, a list, dict, tuple, or set. In contrast, isinstance() only tests whether an object matches a specific type you already suspect, id() returns an object's unique memory identifier, and object() is used to instantiate the base class rather than inspect an existing object's type.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!