Python 3: list atributes within a class object

Posted by MadSc13ntist on Stack Overflow See other posts from Stack Overflow or by MadSc13ntist
Published on 2010-04-20T12:28:35Z Indexed on 2010/04/20 12:33 UTC
Read the original article Hit count: 151

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about python

Related posts about class