Created
September 18, 2019 22:03
-
-
Save duncangh/c45a68eed983e9edf57a16b0c37060fd to your computer and use it in GitHub Desktop.
Python 'type' object to string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://stackoverflow.com/questions/5008828/convert-a-python-type-object-to-a-string | |
| type_variety_list : list = [ | |
| 10, | |
| 'x', | |
| lambda x: x, | |
| set(), | |
| dict(), | |
| [] | |
| ] | |
| types_of_elems_as_strings : list = [type(element).__name__ for element in type_variety_list] | |
| print(types_of_elems_as_strings) | |
| >>> ['int', 'str', 'function', 'set', 'dict', 'list'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment