Question #166

What is the type of the object below?
str(("Python".encode()))

The type of str(("Python".encode())) is a string. Even though "Python" is first encoded to a bytes object, the str() function then casts it to a string. Interestingly enough, the representation of str(("Python".encode())) will contain the bytes literal suffix e.g. b'Python' . (docs.python.org/3/c-api/bytes.html)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵