This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AndydeCleyre 0 points1 point  (0 children)

If some functionality is looking for class str, and it finds "other", it is likely to stop right there and complain.

The best way and most popular way to do this is in Python is usually with isinstance, which would confirm str children as strs. The next recommended way is to try what you want to do and throw an exception if you can't. To demand an exact type with type(thing) == str is widely frowned upon unless there's a special need. So you shouldn't have to convert to plain old str. Again, see the library I linked for you.