Created
March 23, 2021 11:01
-
-
Save bauergeorg/fd3ee19c807a4717a48457c5d5db95a0 to your computer and use it in GitHub Desktop.
return list of class variables
This file contains 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
class obj_list(): | |
element = 'one' | |
lamb = 'two' | |
def show(): | |
""" returns a list of class variables """ | |
return [attr for attr in dir(obj_list) if not callable(getattr(obj_list, attr)) and not attr.startswith("__")] | |
print(obj_list.show()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Terminal Output: ['element', 'lamb']