attributes = [ attr for attr in list(vars(MyClass)) if attr[0] is not '_' and
type(vars(MyClass)[attr]) is not type(lambda :0) ]
This outputs the following:
print(attributes)
>>> ['list1', 'list2']
If you have a methods in your class, "attributes" will not contain your methods' names:
class MyClass():
list1 = [1,2,3]
list2 = ['a','b','c']
def __init__(self, size, speed):
self.size = size
self.speed = speed
def energy(self, size, speed):
return 0.5*size*speed**2
attributes = [ attr for attr in list(vars(MyClass)) if attr[0] is not '_' and
type(vars(MyClass)[attr]) is not type(lambda :0) ]
print(attributes)
>>>['list1', 'list2']