Python 3: list atributes within a class object
- by MadSc13ntist
is there a way that if the following class is created; I can grab a list of attributes that exist. (this class is just an bland example, it is not my task at hand)
class new_class():
def __init__(self, number):
self.multi = int(number) * 2
self.str = str(number)
a = new_class(2)
print(', '.join(a.SOMETHING))
* the attempt is that "multi, str" will print. the point here is that if a class object has attributes added at different parts of a script that I can grab a quick listing of the attributes which are defined.