Skip to content

Instantly share code, notes, and snippets.

@bauergeorg
Created March 23, 2021 11:01
Show Gist options
  • Save bauergeorg/fd3ee19c807a4717a48457c5d5db95a0 to your computer and use it in GitHub Desktop.
Save bauergeorg/fd3ee19c807a4717a48457c5d5db95a0 to your computer and use it in GitHub Desktop.
return list of class variables
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())
@bauergeorg
Copy link
Author

Terminal Output: ['element', 'lamb']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment